mirror of
https://github.com/ysoftdevs/DependencyCheck.git
synced 2026-05-01 04:34:45 +02:00
java7 updates and cleanup
This commit is contained in:
@@ -36,7 +36,7 @@ public class ExpectedOjectInputStream extends ObjectInputStream {
|
||||
/**
|
||||
* The list of fully qualified class names that are able to be deserialized.
|
||||
*/
|
||||
private List<String> expected = new ArrayList<String>();
|
||||
private List<String> expected = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Constructs a new ExpectedOjectInputStream that can be used to securely deserialize an object by restricting the classes
|
||||
|
||||
@@ -283,7 +283,7 @@ public class SSLSocketFactoryEx extends SSLSocketFactory {
|
||||
}
|
||||
}
|
||||
|
||||
final List<String> aa = new ArrayList<String>();
|
||||
final List<String> aa = new ArrayList<>();
|
||||
for (String preferredProtocol : preferredProtocols) {
|
||||
final int idx = Arrays.binarySearch(availableProtocols, preferredProtocol);
|
||||
if (idx >= 0) {
|
||||
|
||||
@@ -49,7 +49,7 @@ public final class Settings {
|
||||
/**
|
||||
* Thread local settings.
|
||||
*/
|
||||
private static final ThreadLocal<Settings> LOCAL_SETTINGS = new ThreadLocal<Settings>();
|
||||
private static final ThreadLocal<Settings> LOCAL_SETTINGS = new ThreadLocal<>();
|
||||
/**
|
||||
* The properties.
|
||||
*/
|
||||
@@ -530,9 +530,7 @@ public final class Settings {
|
||||
private static void logProperties(String header, Properties properties) {
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
final StringWriter sw = new StringWriter();
|
||||
PrintWriter pw = null;
|
||||
try {
|
||||
pw = new PrintWriter(sw);
|
||||
try (PrintWriter pw = new PrintWriter(sw)) {
|
||||
pw.format("%s:%n%n", header);
|
||||
final Enumeration<?> e = properties.propertyNames();
|
||||
while (e.hasMoreElements()) {
|
||||
@@ -548,10 +546,6 @@ public final class Settings {
|
||||
}
|
||||
pw.flush();
|
||||
LOGGER.debug(sw.toString());
|
||||
} finally {
|
||||
if (pw != null) {
|
||||
pw.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ package org.owasp.dependencycheck.utils;
|
||||
import java.io.File;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import org.junit.Test;
|
||||
import org.owasp.dependencycheck.utils.Downloader;
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@@ -69,15 +69,16 @@ public class ExpectedOjectInputStreamTest {
|
||||
*/
|
||||
@Test(expected = java.io.InvalidClassException.class)
|
||||
public void testResolveClassException() throws Exception {
|
||||
List<SimplePojo> data = new ArrayList<SimplePojo>();
|
||||
List<SimplePojo> data = new ArrayList<>();
|
||||
data.add(new SimplePojo());
|
||||
|
||||
ByteArrayOutputStream mem = new ByteArrayOutputStream();
|
||||
ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(mem));
|
||||
out.writeObject(data);
|
||||
out.flush();
|
||||
byte[] buf = mem.toByteArray();
|
||||
out.close();
|
||||
byte[] buf;
|
||||
try (ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(mem))) {
|
||||
out.writeObject(data);
|
||||
out.flush();
|
||||
buf = mem.toByteArray();
|
||||
}
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(buf);
|
||||
|
||||
ExpectedOjectInputStream instance = new ExpectedOjectInputStream(in, "java.util.ArrayList", "org.owasp.dependencycheck.utils.SimplePojo");
|
||||
|
||||
Reference in New Issue
Block a user