@@ -99,12 +99,7 @@ public final class ExpandProperties | |||||
getProperty = PropertyHelper.getPropertyHelper(project); | getProperty = PropertyHelper.getPropertyHelper(project); | ||||
} else { | } else { | ||||
final Properties props = propertySet.getProperties(); | final Properties props = propertySet.getProperties(); | ||||
getProperty = new GetProperty() { | |||||
public Object getProperty(String name) { | |||||
return props.getProperty(name); | |||||
} | |||||
}; | |||||
getProperty = props::getProperty; | |||||
} | } | ||||
Object expanded = new ParseProperties(project, PropertyHelper | Object expanded = new ParseProperties(project, PropertyHelper | ||||
.getPropertyHelper(project) | .getPropertyHelper(project) | ||||
@@ -354,16 +354,14 @@ public final class SortFilter extends BaseParamFilterReader | |||||
private void sort() { | private void sort() { | ||||
if (comparator == null) { | if (comparator == null) { | ||||
if (reverse) { | if (reverse) { | ||||
Collections.sort(lines, new Comparator<String>() { | |||||
public int compare(String s1, String s2) { | |||||
return (-s1.compareTo(s2)); //NOSONAR | |||||
} | |||||
}); | |||||
lines.sort((s1, s2) -> { | |||||
return -s1.compareTo(s2); //NOSONAR | |||||
}); | |||||
} else { | } else { | ||||
Collections.sort(lines); | Collections.sort(lines); | ||||
} | } | ||||
} else { | } else { | ||||
Collections.sort(lines, comparator); | |||||
lines.sort(comparator); | |||||
} | } | ||||
} | } | ||||
} | } |
@@ -492,7 +492,7 @@ public final class Locator { | |||||
} | } | ||||
File[] matches = location.listFiles((dir, name) -> { | File[] matches = location.listFiles((dir, name) -> { | ||||
String littleName = name.toLowerCase(Locale.ENGLISH); | String littleName = name.toLowerCase(Locale.ENGLISH); | ||||
return Stream.of(extensions).anyMatch(x -> littleName.endsWith(x)); | |||||
return Stream.of(extensions).anyMatch(littleName::endsWith); | |||||
}); | }); | ||||
urls = new URL[matches.length]; | urls = new URL[matches.length]; | ||||
for (int i = 0; i < matches.length; ++i) { | for (int i = 0; i < matches.length; ++i) { | ||||
@@ -503,12 +503,7 @@ public class Concat extends Task implements ResourceCollection { | |||||
} | } | ||||
}; | }; | ||||
private ReaderFactory<Reader> identityReaderFactory = new ReaderFactory<Reader>() { | |||||
@Override | |||||
public Reader getReader(Reader o) { | |||||
return o; | |||||
} | |||||
}; | |||||
private ReaderFactory<Reader> identityReaderFactory = o -> o; | |||||
/** | /** | ||||
* Construct a new Concat task. | * Construct a new Concat task. | ||||
@@ -30,7 +30,6 @@ import java.io.Reader; | |||||
import java.io.Writer; | import java.io.Writer; | ||||
import java.nio.file.Files; | import java.nio.file.Files; | ||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.Collections; | |||||
import java.util.Comparator; | import java.util.Comparator; | ||||
import java.util.Iterator; | import java.util.Iterator; | ||||
import java.util.List; | import java.util.List; | ||||
@@ -940,8 +939,8 @@ public class Replace extends MatchingTask { | |||||
*/ | */ | ||||
private Iterator<Object> getOrderedIterator(Properties props) { | private Iterator<Object> getOrderedIterator(Properties props) { | ||||
List<Object> keys = new ArrayList<>(props.keySet()); | List<Object> keys = new ArrayList<>(props.keySet()); | ||||
Collections.sort(keys, Comparator | |||||
.comparingInt(o -> Objects.toString(o, "").length()).reversed()); | |||||
keys.sort(Comparator.comparingInt(o -> Objects.toString(o, "").length()) | |||||
.reversed()); | |||||
return keys.iterator(); | return keys.iterator(); | ||||
} | } | ||||
} | } |
@@ -26,7 +26,6 @@ import java.nio.file.Files; | |||||
import java.text.ParseException; | import java.text.ParseException; | ||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.Arrays; | import java.util.Arrays; | ||||
import java.util.Collections; | |||||
import java.util.Comparator; | import java.util.Comparator; | ||||
import java.util.HashMap; | import java.util.HashMap; | ||||
import java.util.Hashtable; | import java.util.Hashtable; | ||||
@@ -1632,7 +1631,7 @@ public class Zip extends MatchingTask { | |||||
} | } | ||||
// make sure directories are in alpha-order - this also | // make sure directories are in alpha-order - this also | ||||
// ensures parents come before their children | // ensures parents come before their children | ||||
Collections.sort(dirs, Comparator.comparing(Resource::getName)); | |||||
dirs.sort(Comparator.comparing(Resource::getName)); | |||||
final List<Resource> rs = new ArrayList<>(dirs); | final List<Resource> rs = new ArrayList<>(dirs); | ||||
rs.addAll(files); | rs.addAll(files); | ||||
result[i] = rs.toArray(new Resource[rs.size()]); | result[i] = rs.toArray(new Resource[rs.size()]); | ||||
@@ -122,16 +122,13 @@ public class VmsCommandLauncher extends Java13CommandLauncher { | |||||
} | } | ||||
private void deleteAfter(final File f, final Process p) { | private void deleteAfter(final File f, final Process p) { | ||||
new Thread() { | |||||
@Override | |||||
public void run() { | |||||
try { | |||||
p.waitFor(); | |||||
} catch(InterruptedException e) { | |||||
// ignore | |||||
} | |||||
FileUtils.delete(f); | |||||
new Thread(() -> { | |||||
try { | |||||
p.waitFor(); | |||||
} catch(InterruptedException e) { | |||||
// ignore | |||||
} | } | ||||
}.start(); | |||||
FileUtils.delete(f); | |||||
}).start(); | |||||
} | } | ||||
} | } |
@@ -185,10 +185,8 @@ public class XMLResultAggregator extends Task implements XMLConstants { | |||||
DirectoryScanner ds = fs.getDirectoryScanner(p); | DirectoryScanner ds = fs.getDirectoryScanner(p); | ||||
ds.scan(); | ds.scan(); | ||||
return Stream.of(ds.getIncludedFiles()) | return Stream.of(ds.getIncludedFiles()) | ||||
.filter(pathname -> pathname.endsWith(".xml")).map(pathname -> { | |||||
return p.resolveFile( | |||||
new File(ds.getBasedir(), pathname).getPath()); | |||||
}); | |||||
.filter(pathname -> pathname.endsWith(".xml")) | |||||
.map(pathname -> p.resolveFile(new File(ds.getBasedir(), pathname).getPath())); | |||||
}).toArray(File[]::new); | }).toArray(File[]::new); | ||||
} | } | ||||
@@ -395,21 +395,18 @@ public class SSHExec extends SSHBase { | |||||
channel.connect(); | channel.connect(); | ||||
// wait for it to finish | // wait for it to finish | ||||
thread = | thread = | ||||
new Thread() { | |||||
@Override | |||||
public void run() { | |||||
new Thread(() -> { | |||||
while (!channel.isClosed()) { | while (!channel.isClosed()) { | ||||
if (thread == null) { | if (thread == null) { | ||||
return; | return; | ||||
} | } | ||||
try { | try { | ||||
sleep(RETRY_INTERVAL); | |||||
Thread.sleep(RETRY_INTERVAL); | |||||
} catch (final Exception e) { | } catch (final Exception e) { | ||||
// ignored | // ignored | ||||
} | } | ||||
} | } | ||||
} | |||||
}; | |||||
}); | |||||
thread.start(); | thread.start(); | ||||
thread.join(maxwait); | thread.join(maxwait); | ||||
@@ -267,11 +267,7 @@ public class URLResource extends Resource implements URLProvider { | |||||
if (!isExists(false)) { | if (!isExists(false)) { | ||||
return UNKNOWN_DATETIME; | return UNKNOWN_DATETIME; | ||||
} | } | ||||
return withConnection(new ConnectionUser() { | |||||
public long useConnection(URLConnection c) { | |||||
return conn.getLastModified(); | |||||
} | |||||
}, UNKNOWN_DATETIME); | |||||
return withConnection(c -> conn.getLastModified(), UNKNOWN_DATETIME); | |||||
} | } | ||||
/** | /** | ||||
@@ -296,11 +292,7 @@ public class URLResource extends Resource implements URLProvider { | |||||
if (!isExists(false)) { | if (!isExists(false)) { | ||||
return 0L; | return 0L; | ||||
} | } | ||||
return withConnection(new ConnectionUser() { | |||||
public long useConnection(URLConnection c) { | |||||
return conn.getContentLength(); | |||||
} | |||||
}, UNKNOWN_SIZE); | |||||
return withConnection(c -> conn.getContentLength(), UNKNOWN_SIZE); | |||||
} | } | ||||
/** | /** | ||||
@@ -179,12 +179,10 @@ public class JavaxScriptRunner extends ScriptRunnerBase { | |||||
if ("FX".equalsIgnoreCase(getLanguage())) { | if ("FX".equalsIgnoreCase(getLanguage())) { | ||||
source = source.entrySet().stream() | source = source.entrySet().stream() | ||||
.collect(Collectors.toMap( | |||||
e -> String.format("%s:%s", e.getKey(), | |||||
e.getValue().getClass().getName()), | |||||
Map.Entry::getValue)); | |||||
.collect(Collectors.toMap(e -> String.format("%s:%s", e.getKey(), | |||||
e.getValue().getClass().getName()), Map.Entry::getValue)); | |||||
} | } | ||||
source.forEach(target::accept); | |||||
source.forEach(target); | |||||
} | } | ||||
private ScriptEngine createEngine() { | private ScriptEngine createEngine() { | ||||
@@ -297,12 +297,10 @@ public class ProjectTest { | |||||
} | } | ||||
}); | }); | ||||
final boolean[] done = new boolean[] {false}; | final boolean[] done = new boolean[] {false}; | ||||
Thread t = new Thread() { | |||||
public void run() { | |||||
p.log(FOO, Project.MSG_INFO); | |||||
done[0] = true; | |||||
} | |||||
}; | |||||
Thread t = new Thread(() -> { | |||||
p.log(FOO, Project.MSG_INFO); | |||||
done[0] = true; | |||||
}); | |||||
t.start(); | t.start(); | ||||
t.join(2000); | t.join(2000); | ||||
assertTrue("Expected logging thread to finish successfully", done[0]); | assertTrue("Expected logging thread to finish successfully", done[0]); | ||||
@@ -136,16 +136,14 @@ public class ExecuteWatchdogTest { | |||||
watchdog.start(process); | watchdog.start(process); | ||||
// I assume that starting this takes less than TIME_OUT/2 ms... | // I assume that starting this takes less than TIME_OUT/2 ms... | ||||
Thread thread = new Thread() { | |||||
public void run() { | |||||
try { | |||||
process.waitFor(); | |||||
} catch(InterruptedException e) { | |||||
// not very nice but will do the job | |||||
throw new AssumptionViolatedException("process interrupted in thread", e); | |||||
} | |||||
} | |||||
}; | |||||
Thread thread = new Thread(() -> { | |||||
try { | |||||
process.waitFor(); | |||||
} catch(InterruptedException e) { | |||||
// not very nice but will do the job | |||||
throw new AssumptionViolatedException("process interrupted in thread", e); | |||||
} | |||||
}); | |||||
thread.start(); | thread.start(); | ||||
// wait for TIME_OUT / 2, there should be about TIME_OUT / 2 ms remaining before timeout | // wait for TIME_OUT / 2, there should be about TIME_OUT / 2 ms remaining before timeout | ||||
@@ -383,13 +383,11 @@ public class JavaTest { | |||||
// reader will be read | // reader will be read | ||||
java.execute(); | java.execute(); | ||||
Thread inputThread = new Thread(new Runnable() { | |||||
public void run() { | |||||
Input input = new Input(); | |||||
input.setProject(buildRule.getProject()); | |||||
input.setAddproperty("input.value"); | |||||
input.execute(); | |||||
} | |||||
Thread inputThread = new Thread(() -> { | |||||
Input input = new Input(); | |||||
input.setProject(buildRule.getProject()); | |||||
input.setAddproperty("input.value"); | |||||
input.execute(); | |||||
}); | }); | ||||
inputThread.start(); | inputThread.start(); | ||||
@@ -425,19 +423,17 @@ public class JavaTest { | |||||
final boolean[] timeout = new boolean[1]; | final boolean[] timeout = new boolean[1]; | ||||
timeout[0] = false; | timeout[0] = false; | ||||
Thread writingThread = new Thread(new Runnable() { | |||||
public void run() { | |||||
try { | |||||
// wait a little bit to have the target executed | |||||
Thread.sleep(500); | |||||
} catch (InterruptedException e) { | |||||
throw new AssumptionViolatedException("Thread interrupted", e); | |||||
} | |||||
try { | |||||
out.write("foo-FlushedInput\n".getBytes()); | |||||
} catch (IOException e) { | |||||
throw new RuntimeException(e); | |||||
} | |||||
Thread writingThread = new Thread(() -> { | |||||
try { | |||||
// wait a little bit to have the target executed | |||||
Thread.sleep(500); | |||||
} catch (InterruptedException e) { | |||||
throw new AssumptionViolatedException("Thread interrupted", e); | |||||
} | |||||
try { | |||||
out.write("foo-FlushedInput\n".getBytes()); | |||||
} catch (IOException e) { | |||||
throw new RuntimeException(e); | |||||
} | } | ||||
}); | }); | ||||
writingThread.setDaemon(true); | writingThread.setDaemon(true); | ||||
@@ -343,14 +343,12 @@ public class XmlPropertyTest { | |||||
* and below. | * and below. | ||||
*/ | */ | ||||
private static void getFiles (final File startingDir, Vector<File> collect) { | private static void getFiles (final File startingDir, Vector<File> collect) { | ||||
FileFilter filter = new FileFilter() { | |||||
public boolean accept (File file) { | |||||
if (file.isDirectory()) { | |||||
return true; | |||||
} else { | |||||
return (file.getPath().indexOf("taskdefs") > 0 && | |||||
file.getPath().toLowerCase().endsWith(".xml")); | |||||
} | |||||
FileFilter filter = file -> { | |||||
if (file.isDirectory()) { | |||||
return true; | |||||
} else { | |||||
return (file.getPath().indexOf("taskdefs") > 0 && | |||||
file.getPath().toLowerCase().endsWith(".xml")); | |||||
} | } | ||||
}; | }; | ||||
@@ -32,11 +32,7 @@ public class ThreadedOutput extends TestCase { | |||||
} | } | ||||
public void testOutput() throws InterruptedException { | public void testOutput() throws InterruptedException { | ||||
Thread t = new Thread(new Runnable() { | |||||
public void run() { | |||||
System.out.println("foo"); | |||||
} | |||||
}); | |||||
Thread t = new Thread(() -> System.out.println("foo")); | |||||
t.start(); | t.start(); | ||||
t.join(); | t.join(); | ||||
} | } | ||||