Browse Source

Remove redundancies

master
Gintas Grigelionis 6 years ago
parent
commit
77cd591b63
17 changed files with 39 additions and 60 deletions
  1. +2
    -4
      src/main/org/apache/tools/ant/ProjectHelperRepository.java
  2. +7
    -7
      src/main/org/apache/tools/ant/filters/FixCrLfFilter.java
  3. +8
    -29
      src/main/org/apache/tools/ant/taskdefs/AntStructure.java
  4. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/Execute.java
  5. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/InvokeDynamicCPInfo.java
  6. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/MethodHandleCPInfo.java
  7. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/MethodTypeCPInfo.java
  8. +2
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/junit/BriefJUnitResultFormatter.java
  9. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/LauncherSupport.java
  10. +1
    -1
      src/main/org/apache/tools/ant/types/PatternSet.java
  11. +0
    -2
      src/main/org/apache/tools/ant/types/resources/selectors/Majority.java
  12. +3
    -1
      src/main/org/apache/tools/ant/util/FlatFileNameMapper.java
  13. +1
    -1
      src/main/org/apache/tools/ant/util/optional/JavaxScriptRunner.java
  14. +2
    -1
      src/main/org/apache/tools/zip/UnsupportedZipFeatureException.java
  15. +1
    -1
      src/tests/junit/org/apache/tools/ant/taskdefs/DefaultExcludesTest.java
  16. +5
    -5
      src/tests/junit/org/apache/tools/ant/taskdefs/JavaTest.java
  17. +1
    -1
      src/tests/junit/org/apache/tools/ant/util/ReaderInputStreamTest.java

+ 2
- 4
src/main/org/apache/tools/ant/ProjectHelperRepository.java View File

@@ -181,10 +181,8 @@ public class ProjectHelperRepository {
try {
// This code is needed by EBCDIC and other strange systems.
// It's a fix for bugs reported in xerces
InputStreamReader isr;
isr = new InputStreamReader(is, StandardCharsets.UTF_8);
BufferedReader rd = new BufferedReader(isr);

BufferedReader rd = new BufferedReader(new InputStreamReader(is,
StandardCharsets.UTF_8));
String helperClassName = rd.readLine();
rd.close();



+ 7
- 7
src/main/org/apache/tools/ant/filters/FixCrLfFilter.java View File

@@ -442,11 +442,11 @@ public final class FixCrLfFilter extends BaseParamFilterReader implements Chaina
return in instanceof SimpleFilterReader && ((SimpleFilterReader) in).editsBlocked();
}

public int read() throws java.io.IOException {
public int read() throws IOException {
return preemptIndex > 0 ? preempt[--preemptIndex] : in.read();
}

public void close() throws java.io.IOException {
public void close() throws IOException {
in.close();
}

@@ -458,23 +458,23 @@ public final class FixCrLfFilter extends BaseParamFilterReader implements Chaina
return in.markSupported();
}

public boolean ready() throws java.io.IOException {
public boolean ready() throws IOException {
return in.ready();
}

public void mark(int i) throws java.io.IOException {
public void mark(int i) throws IOException {
in.mark(i);
}

public long skip(long i) throws java.io.IOException {
public long skip(long i) throws IOException {
return in.skip(i);
}

public int read(char[] buf) throws java.io.IOException {
public int read(char[] buf) throws IOException {
return read(buf, 0, buf.length);
}

public int read(char[] buf, int start, int length) throws java.io.IOException {
public int read(char[] buf, int start, int length) throws IOException {
int count = 0;
int c = 0;



+ 8
- 29
src/main/org/apache/tools/ant/taskdefs/AntStructure.java View File

@@ -87,22 +87,8 @@ public class AntStructure extends Task {
throw new BuildException("output attribute is required", getLocation());
}

PrintWriter out = null;
try {
OutputStream fos = null;
try {
fos = Files.newOutputStream(output.toPath());
out = new PrintWriter(new OutputStreamWriter(fos, StandardCharsets.UTF_8));
} catch (final UnsupportedEncodingException ue) {
FileUtils.close(fos);
/*
* Plain impossible with UTF8, see
* http://java.sun.com/j2se/1.5.0/docs/guide/intl/encoding.doc.html
*
* fallback to platform specific anyway.
*/
out = new PrintWriter(new FileWriter(output));
}
try (PrintWriter out = new PrintWriter(new OutputStreamWriter(
Files.newOutputStream(output.toPath()), StandardCharsets.UTF_8))) {

printer.printHead(out, getProject(),
new Hashtable<>(getProject().getTaskDefinitions()),
@@ -110,31 +96,24 @@ public class AntStructure extends Task {

printer.printTargetDecl(out);

for (final String typeName : getProject().getCopyOfDataTypeDefinitions()
.keySet()) {
printer.printElementDecl(
out, getProject(), typeName,
getProject().getDataTypeDefinitions().get(typeName));
for (final String typeName : getProject().getCopyOfDataTypeDefinitions().keySet()) {
printer.printElementDecl(out, getProject(), typeName,
getProject().getDataTypeDefinitions().get(typeName));
}

for (final String tName : getProject().getCopyOfTaskDefinitions().keySet()) {
printer.printElementDecl(out, getProject(), tName,
getProject().getTaskDefinitions().get(tName));
getProject().getTaskDefinitions().get(tName));
}

printer.printTail(out);

if (out.checkError()) {
throw new IOException(
"Encountered an error writing Ant structure");
throw new IOException("Encountered an error writing Ant structure");
}
} catch (final IOException ioe) {
throw new BuildException("Error writing "
+ output.getAbsolutePath(), ioe, getLocation());
} finally {
if (out != null) {
out.close();
}
+ output.getAbsolutePath(), ioe, getLocation());
}
}



+ 2
- 2
src/main/org/apache/tools/ant/taskdefs/Execute.java View File

@@ -428,7 +428,7 @@ public class Execute {
* Runs a process defined by the command line and returns its exit status.
*
* @return the exit status of the subprocess or <code>INVALID</code>.
* @exception java.io.IOException The exception is thrown, if launching
* @exception IOException The exception is thrown, if launching
* of the subprocess failed.
*/
public int execute() throws IOException {
@@ -484,7 +484,7 @@ public class Execute {
* Starts a process defined by the command line.
* Ant will not wait for this process, nor log its output.
*
* @throws java.io.IOException The exception is thrown, if launching
* @throws IOException The exception is thrown, if launching
* of the subprocess failed.
* @since Ant 1.6
*/


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/InvokeDynamicCPInfo.java View File

@@ -43,7 +43,7 @@ public class InvokeDynamicCPInfo extends ConstantCPInfo {
*
* @param cpStream the DataInputStream which contains the constant pool
* entry to be read.
* @exception java.io.IOException if there is a problem reading the entry from
* @exception IOException if there is a problem reading the entry from
* the stream.
*/
@Override


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/MethodHandleCPInfo.java View File

@@ -58,7 +58,7 @@ public class MethodHandleCPInfo extends ConstantPoolEntry {
*
* @param cpStream the DataInputStream which contains the constant pool
* entry to be read.
* @exception java.io.IOException if there is a problem reading the entry from
* @exception IOException if there is a problem reading the entry from
* the stream.
*/
@Override


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/MethodTypeCPInfo.java View File

@@ -41,7 +41,7 @@ public class MethodTypeCPInfo extends ConstantCPInfo {
*
* @param cpStream the DataInputStream which contains the constant pool
* entry to be read.
* @exception java.io.IOException if there is a problem reading the entry from
* @exception IOException if there is a problem reading the entry from
* the stream.
*/
@Override


+ 2
- 1
src/main/org/apache/tools/ant/taskdefs/optional/junit/BriefJUnitResultFormatter.java View File

@@ -21,6 +21,7 @@ package org.apache.tools.ant.taskdefs.optional.junit;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.StringWriter;
import java.text.NumberFormat;

@@ -91,7 +92,7 @@ public class BriefJUnitResultFormatter implements JUnitResultFormatter, IgnoredT
@Override
public void setOutput(OutputStream out) {
this.out = out;
output = new BufferedWriter(new java.io.OutputStreamWriter(out));
output = new BufferedWriter(new OutputStreamWriter(out));
}

/**


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/LauncherSupport.java View File

@@ -238,7 +238,7 @@ class LauncherSupport {
throw new BuildException("Listener class " + className + " is not of type " + TestExecutionListener.class.getName());
}
try {
return TestExecutionListener.class.cast(klass.newInstance());
return (TestExecutionListener) klass.newInstance();
} catch (Exception e) {
throw new BuildException("Failed to create an instance of listener " + className, e);
}


+ 1
- 1
src/main/org/apache/tools/ant/types/PatternSet.java View File

@@ -218,7 +218,7 @@ public class PatternSet extends DataType implements Cloneable {
public String toString() {
String baseString = super.toString();
return encoding == null ? baseString
: new StringBuilder(baseString).append(";encoding->").append(encoding).toString();
: baseString + ";encoding->" + encoding;
}
}



+ 0
- 2
src/main/org/apache/tools/ant/types/resources/selectors/Majority.java View File

@@ -17,8 +17,6 @@
*/
package org.apache.tools.ant.types.resources.selectors;

import java.util.Iterator;

import org.apache.tools.ant.types.Resource;

/**


+ 3
- 1
src/main/org/apache/tools/ant/util/FlatFileNameMapper.java View File

@@ -18,6 +18,8 @@

package org.apache.tools.ant.util;

import java.io.File;

/**
* Implementation of FileNameMapper that always returns the source
* file name without any leading directory information.
@@ -53,6 +55,6 @@ public class FlatFileNameMapper implements FileNameMapper {
@Override
public String[] mapFileName(String sourceFileName) {
return sourceFileName == null ? null
: new String[] {new java.io.File(sourceFileName).getName()};
: new String[] {new File(sourceFileName).getName()};
}
}

+ 1
- 1
src/main/org/apache/tools/ant/util/optional/JavaxScriptRunner.java View File

@@ -110,7 +110,7 @@ public class JavaxScriptRunner extends ScriptRunnerBase {
"Unable to create javax script engine for %s",
getLanguage());
}
if (Compilable.class.isInstance(engine)) {
if (engine instanceof Compilable) {
getProject().log("compile script " + execName,
Project.MSG_VERBOSE);



+ 2
- 1
src/main/org/apache/tools/zip/UnsupportedZipFeatureException.java View File

@@ -18,6 +18,7 @@

package org.apache.tools.zip;

import java.io.Serializable;
import java.util.zip.ZipException;

/**
@@ -66,7 +67,7 @@ public class UnsupportedZipFeatureException extends ZipException {
* ZIP Features that may or may not be supported.
*/
@SuppressWarnings("serial")
public static class Feature implements java.io.Serializable {
public static class Feature implements Serializable {
/**
* The entry is encrypted.
*/


+ 1
- 1
src/tests/junit/org/apache/tools/ant/taskdefs/DefaultExcludesTest.java View File

@@ -161,7 +161,7 @@ public class DefaultExcludesTest {
assertEquals("current default excludes: string array length match", expected.length, actual.length);
for (String element : expected) {
assertTrue("current default excludes: didn't find element " + element + " in array match",
Arrays.stream(actual).anyMatch(member -> member.equals(element)));
Arrays.asList(actual).contains(element));
}
}
}

+ 5
- 5
src/tests/junit/org/apache/tools/ant/taskdefs/JavaTest.java View File

@@ -418,7 +418,7 @@ public class JavaTest {
* @throws Exception
*/
@Test
public void testSimpleSourceFile() throws Exception {
public void testSimpleSourceFile() {
requireJava11();
buildRule.executeTarget("simpleSourceFile");
}
@@ -429,7 +429,7 @@ public class JavaTest {
* @throws Exception
*/
@Test
public void testSourceFileRequiresFork() throws Exception {
public void testSourceFileRequiresFork() {
requireJava11();
thrown.expect(BuildException.class);
thrown.expectMessage("Cannot execute sourcefile in non-forked mode. Please set fork='true'");
@@ -443,7 +443,7 @@ public class JavaTest {
* @throws Exception
*/
@Test
public void testSourceFileCantUseClassname() throws Exception {
public void testSourceFileCantUseClassname() {
requireJava11();
thrown.expect(BuildException.class);
thrown.expectMessage("Cannot use 'sourcefile' in combination with");
@@ -457,7 +457,7 @@ public class JavaTest {
* @throws Exception
*/
@Test
public void testSourceFileCantUseJar() throws Exception {
public void testSourceFileCantUseJar() {
requireJava11();
thrown.expect(BuildException.class);
thrown.expectMessage("Cannot use 'sourcefile' in combination with");
@@ -471,7 +471,7 @@ public class JavaTest {
* @throws Exception
*/
@Test
public void testSourceFileCantUseModule() throws Exception {
public void testSourceFileCantUseModule() {
requireJava11();
thrown.expect(BuildException.class);
thrown.expectMessage("Cannot use 'sourcefile' in combination with");


+ 1
- 1
src/tests/junit/org/apache/tools/ant/util/ReaderInputStreamTest.java View File

@@ -81,7 +81,7 @@ public class ReaderInputStreamTest {
}

@Test
public void testPreample() throws Exception {
public void testPreample() {
byte[] bytes = "".getBytes(StandardCharsets.UTF_16);
System.out.println("Preample len is " + bytes.length);
}


Loading…
Cancel
Save