Skip to content
Permalink
Browse files
TENTACLES-12: Update to JDK9 and log4jx2
  • Loading branch information
ottlinger committed Dec 15, 2020
1 parent b2b2a86 commit 93014099f89bba4f427f4e7403cb66ff6aa02bce
Showing 4 changed files with 100 additions and 135 deletions.
32 pom.xml
@@ -64,6 +64,11 @@
<artifactId>velocity</artifactId>
<version>1.7</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>org.codehaus.swizzle</groupId>
<artifactId>swizzle-stream</artifactId>
@@ -149,33 +154,6 @@
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>animal-sniffer-maven-plugin</artifactId>
<version>1.19</version>
<executions>
<execution>
<!-- This checks the source code of our project -->
<!--
Note that this cannot use our ${javaVersion} property, so it must
be changed manually when we decide to move to a higher version of
Java
-->
<id>check-java-1.9-compat</id>
<phase>process-classes</phase>
<goals>
<goal>check</goal>
</goals>
<configuration>
<signature>
<groupId>org.codehaus.mojo.signature</groupId>
<artifactId>java9</artifactId>
<version>1.0</version>
</signature>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
@@ -16,117 +16,109 @@
*/
package org.apache.creadur.tentacles;

import org.apache.log4j.Logger;

import org.apache.logging.log4j.*;
import java.io.*;
import java.net.URL;
import java.util.zip.ZipInputStream;

/**
* @version $Rev$ $Date$
*/
public class IOSystem {
private static final Logger LOG = Logger.getLogger(IOSystem.class);
private static final Logger LOG = LogManager.getLogger(IOSystem.class);

public String slurp(final File file) throws IOException {
final ByteArrayOutputStream out = new ByteArrayOutputStream();
copy(file, out);
return new String(out.toByteArray());
}
public String slurp(final File file) throws IOException {
final ByteArrayOutputStream out = new ByteArrayOutputStream();
copy(file, out);
return new String(out.toByteArray());
}

public String slurp(final URL url) throws IOException {
final ByteArrayOutputStream out = new ByteArrayOutputStream();
copy(url.openStream(), out);
return new String(out.toByteArray());
}
public String slurp(final URL url) throws IOException {
final ByteArrayOutputStream out = new ByteArrayOutputStream();
copy(url.openStream(), out);
return new String(out.toByteArray());
}

public void writeString(final File file, final String string)
throws IOException {
final FileWriter out = new FileWriter(file);
try {
final BufferedWriter bufferedWriter = new BufferedWriter(out);
try {
bufferedWriter.write(string);
bufferedWriter.newLine();
} finally {
close(bufferedWriter);
}
} finally {
close(out);
}
}
public void writeString(final File file, final String string) throws IOException {
final FileWriter out = new FileWriter(file);
try {
final BufferedWriter bufferedWriter = new BufferedWriter(out);
try {
bufferedWriter.write(string);
bufferedWriter.newLine();
} finally {
close(bufferedWriter);
}
} finally {
close(out);
}
}

private void copy(final File from, final OutputStream to)
throws IOException {
final InputStream read = read(from);
try {
copy(read, to);
} finally {
close(read);
}
}
private void copy(final File from, final OutputStream to) throws IOException {
final InputStream read = read(from);
try {
copy(read, to);
} finally {
close(read);
}
}

public void copy(final InputStream from, final File to) throws IOException {
final OutputStream write = write(to);
try {
copy(from, write);
} finally {
close(write);
}
}
public void copy(final InputStream from, final File to) throws IOException {
final OutputStream write = write(to);
try {
copy(from, write);
} finally {
close(write);
}
}

private void copy(final InputStream from, final OutputStream to)
throws IOException {
final byte[] buffer = new byte[1024];
int length = 0;
while ((length = from.read(buffer)) != -1) {
to.write(buffer, 0, length);
}
to.flush();
}
private void copy(final InputStream from, final OutputStream to) throws IOException {
final byte[] buffer = new byte[1024];
int length = 0;
while ((length = from.read(buffer)) != -1) {
to.write(buffer, 0, length);
}
to.flush();
}

public void copy(final byte[] from, final File to) throws IOException {
copy(new ByteArrayInputStream(from), to);
}
public void copy(final byte[] from, final File to) throws IOException {
copy(new ByteArrayInputStream(from), to);
}

public ZipInputStream unzip(final File file) throws IOException {
final InputStream read = read(file);
return new ZipInputStream(read);
}
public ZipInputStream unzip(final File file) throws IOException {
final InputStream read = read(file);
return new ZipInputStream(read);
}

public void close(final Closeable closeable) throws IOException {
if (closeable == null) {
return;
}
try {
if (closeable instanceof Flushable) {
((Flushable) closeable).flush();
}
} catch (final IOException e) {
LOG.trace("Error when trying to flush before closing " + closeable, e);
}
try {
closeable.close();
} catch (final IOException e) {
LOG.trace("Error when trying to close " + closeable, e);
}
}
public void close(final Closeable closeable) throws IOException {
if (closeable == null) {
return;
}
try {
if (closeable instanceof Flushable) {
((Flushable) closeable).flush();
}
} catch (final IOException e) {
LOG.trace("Error when trying to flush before closing " + closeable, e);
}
try {
closeable.close();
} catch (final IOException e) {
LOG.trace("Error when trying to close " + closeable, e);
}
}

public OutputStream write(final File destination)
throws FileNotFoundException {
final OutputStream out = new FileOutputStream(destination);
return new BufferedOutputStream(out, 32768);
}
public OutputStream write(final File destination) throws FileNotFoundException {
final OutputStream out = new FileOutputStream(destination);
return new BufferedOutputStream(out, 32768);
}

public InputStream read(final File source) throws FileNotFoundException {
final InputStream in = new FileInputStream(source);
return new BufferedInputStream(in, 32768);
}
public InputStream read(final File source) throws FileNotFoundException {
final InputStream in = new FileInputStream(source);
return new BufferedInputStream(in, 32768);
}

public byte[] read(final InputStream in) throws IOException {
final ByteArrayOutputStream out = new ByteArrayOutputStream();
copy(in, out);
out.close();
return out.toByteArray();
}
public byte[] read(final InputStream in) throws IOException {
final ByteArrayOutputStream out = new ByteArrayOutputStream();
copy(in, out);
out.close();
return out.toByteArray();
}
}
@@ -34,25 +34,20 @@
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

import org.apache.log4j.ConsoleAppender;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout;
import org.apache.logging.log4j.*;

/**
* @version $Rev$ $Date$
*/
public class Main {

static {
final Logger root = Logger.getRootLogger();

/* TENTACLES-12: disabled root logger configuration
final Logger root = LogManager.getRootLogger();
root.addAppender(new ConsoleAppender(new PatternLayout(
PatternLayout.TTCC_CONVERSION_PATTERN)));
root.setLevel(Level.INFO);
*/
}

private static final Logger log = Logger.getLogger(Main.class);
private static final Logger log = LogManager.getLogger(Main.class);
private static final String CRAWL_PATTERN = ".*\\.(jar|zip|war|ear|rar|tar.gz)";

private final Reports reports;
@@ -24,7 +24,7 @@
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.*;
import org.codehaus.swizzle.stream.StreamLexer;

import java.io.File;
@@ -36,7 +36,7 @@

public class NexusClient {

private static final Logger log = Logger.getLogger(NexusClient.class);
private static final Logger log = LogManager.getLogger(NexusClient.class);
private static final String SLASH = "/";
private static final String ONE_UP = "../";
private static final String USER_AGENT_CONTENTS = "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101206 Ubuntu/10.10 (maverick) Firefox/3.6.13";

0 comments on commit 9301409

Please sign in to comment.