Skip to content

Commits on Source 5

jboss-logmanager (2.1.5-1) unstable; urgency=medium
* New upstream version 2.1.5.
* Declare compliance with Debian Policy 4.2.1.
* Drop disable-apiviz.patch. No longer needed.
-- Markus Koschany <apo@debian.org> Sat, 06 Oct 2018 11:46:58 +0200
jboss-logmanager (2.1.4-1) unstable; urgency=medium
* New upstream version 2.1.4.
......
......@@ -18,7 +18,7 @@ Build-Depends:
libmaven-source-plugin-java,
libwildfly-common-java,
maven-debian-helper (>= 1.5)
Standards-Version: 4.1.5
Standards-Version: 4.2.1
Vcs-Git: https://anonscm.debian.org/git/pkg-java/jboss-logmanager.git
Vcs-Browser: https://anonscm.debian.org/cgit/pkg-java/jboss-logmanager.git
Homepage: https://github.com/jboss-logging/jboss-logmanager
......
From: Markus Koschany <apo@debian.org>
Date: Tue, 3 Mar 2015 10:58:41 +0100
Subject: disable apiviz
Disable the apiviz JavaDoc doclet because it is not packaged yet.
Forwarded: not-needed
---
pom.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index b85fcf5..12a19f8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -148,7 +148,7 @@
</plugin>
</plugins>
</build>
- <reporting>
+ <!-- <reporting>
<plugins>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
@@ -170,5 +170,5 @@
</configuration>
</plugin>
</plugins>
- </reporting>
+ </reporting> -->
</project>
......@@ -28,7 +28,7 @@
<groupId>org.jboss.logmanager</groupId>
<artifactId>jboss-logmanager</artifactId>
<packaging>jar</packaging>
<version>2.1.4.Final</version>
<version>2.1.5.Final</version>
<parent>
<groupId>org.jboss</groupId>
......@@ -47,15 +47,12 @@
<properties>
<!-- Dependency versions -->
<version.javax.json>1.0</version.javax.json>
<version.org.byteman>4.0.3</version.org.byteman>
<version.org.byteman>4.0.4</version.org.byteman>
<version.org.glassfish.javax.json>1.0.4</version.org.glassfish.javax.json>
<version.org.jboss.modules.jboss-modules>1.7.0.Final</version.org.jboss.modules.jboss-modules>
<version.org.wildfly.common.wildfly-common>1.2.0.Final</version.org.wildfly.common.wildfly-common>
<version.junit.junit>4.12</version.junit.junit>
<!-- Plugin versions -->
<version.org.jboss.apiviz.plugin>1.3.2.GA</version.org.jboss.apiviz.plugin>
<!-- Test properties -->
<org.jboss.test.address>127.0.0.1</org.jboss.test.address>
<org.jboss.test.port>4560</org.jboss.test.port>
......@@ -297,26 +294,4 @@
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<doclet>net.gleamynode.apiviz.APIviz</doclet>
<docletArtifact>
<groupId>org.jboss.apiviz</groupId>
<artifactId>apiviz</artifactId>
<version>${version.org.jboss.apiviz.plugin}</version>
</docletArtifact>
<doctitle>JBoss LogManager ${project.version}</doctitle>
<header>JBoss LogManager ${project.version}</header>
<footer>JBoss LogManager ${project.version}</footer>
<bottom><![CDATA[<i>Copyright &#169; 2017 JBoss, a division of Red Hat, Inc.</i>]]></bottom>
<links>
<link>http://docs.oracle.com/javase/8/docs/api/</link>
</links>
</configuration>
</plugin>
</plugins>
</reporting>
</project>
......@@ -110,6 +110,8 @@ public class ExtLogRecord extends LogRecord {
setSourceMethodName(original.getSourceMethodName());
sourceFileName = original.sourceFileName;
sourceLineNumber = original.sourceLineNumber;
sourceModuleName = original.sourceModuleName;
sourceModuleVersion = original.sourceModuleVersion;
}
formatStyle = original.formatStyle;
mdcCopy = original.mdcCopy;
......
......@@ -111,7 +111,7 @@ public final class FormatStringParser {
break;
}
case 'h': {
stepList.add(Formatters.hostnameFormatStep(leftJustify, minimumWidth, truncateBeginning, maximumWidth, argument == null ? "1" : argument));
stepList.add(Formatters.hostnameFormatStep(leftJustify, minimumWidth, truncateBeginning, maximumWidth, false));
break;
}
case 'H': {
......
......@@ -45,12 +45,12 @@ import org.jboss.logmanager.ExtLogRecord;
/**
* Formatter utility methods.
*/
@SuppressWarnings({"WeakerAccess", "unused"})
public final class Formatters {
public static final String THREAD_ID = "id";
private static final boolean DEFAULT_TRUNCATE_BEGINNING = false;
private static final String NEW_LINE = String.format("%n");
private static final Pattern PRECISION_INT_PATTERN = Pattern.compile("\\d+");
......@@ -547,7 +547,13 @@ public final class Formatters {
* @return the format step
*/
public static FormatStep hostnameFormatStep(final boolean leftJustify, final int minimumWidth, final boolean truncateBeginning, final int maximumWidth, final boolean qualified) {
return hostnameFormatStep(leftJustify, minimumWidth, truncateBeginning, maximumWidth, qualified ? null : "1");
return qualified ? hostnameFormatStep(leftJustify, minimumWidth, truncateBeginning, maximumWidth, null) : new SegmentedFormatStep(leftJustify, minimumWidth, truncateBeginning, maximumWidth, null) {
public String getSegmentedSubject(final ExtLogRecord record) {
final String hostName = record.getHostName();
final int idx = hostName.indexOf('.');
return idx == -1 ? hostName :hostName.substring(0, idx);
}
};
}
/**
......@@ -561,9 +567,30 @@ public final class Formatters {
* @return the format step
*/
public static FormatStep hostnameFormatStep(final boolean leftJustify, final int minimumWidth, final boolean truncateBeginning, final int maximumWidth, final String precision) {
return new SegmentedFormatStep(leftJustify, minimumWidth, truncateBeginning, maximumWidth, precision) {
return new SegmentedFormatStep(leftJustify, minimumWidth, truncateBeginning, maximumWidth, null) {
public String getSegmentedSubject(final ExtLogRecord record) {
return record.getHostName();
final String hostName = record.getHostName();
// Check for a specified precision. This is not passed to the constructor because we want truncate
// segments from the right intsead of the left.
if (precision != null && PRECISION_INT_PATTERN.matcher(precision).matches()) {
int count = Integer.parseInt(precision);
int end = 0;
for (int i = 0; i < hostName.length(); i++) {
// If we've got a dot we're at a new segment
if (hostName.charAt(i) == '.') {
count--;
end = i;
}
// We've reached the precision we want
if (count == 0) {
break;
}
}
if (end != 0 && count == 0) {
return hostName.substring(0, end);
}
}
return hostName;
}
};
}
......
......@@ -25,6 +25,7 @@ import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
import java.nio.charset.Charset;
import java.util.logging.ErrorManager;
import java.util.logging.Formatter;
......@@ -35,6 +36,7 @@ import java.util.logging.Formatter;
public class OutputStreamHandler extends WriterHandler {
private OutputStream outputStream;
private Charset charset;
/**
* Construct a new instance with no formatter.
......@@ -84,10 +86,12 @@ public class OutputStreamHandler extends WriterHandler {
public void setEncoding(final String encoding) throws SecurityException, UnsupportedEncodingException {
// superclass checks access
synchronized (outputLock) {
charset = encoding == null ? null : Charset.forName(encoding);
super.setEncoding(encoding);
if (this.outputStream != null) {
// we only want to change the writer, not the output stream
final OutputStream outputStream = this.outputStream;
updateWriter(outputStream, encoding);
if (outputStream != null) {
super.setWriter(getNewWriter(outputStream));
}
}
}
......@@ -96,32 +100,50 @@ public class OutputStreamHandler extends WriterHandler {
public void setWriter(final Writer writer) {
synchronized (outputLock) {
super.setWriter(writer);
final OutputStream oldStream = this.outputStream;
outputStream = null;
safeFlush(oldStream);
safeClose(oldStream);
}
}
/**
* Set the output stream to write to.
* Set the output stream to write to. The output stream will then belong to this handler; when the handler is
* closed or a new writer or output stream is set, this output stream will be closed.
*
* @param outputStream the new output stream or {@code null} for none
*/
public void setOutputStream(final OutputStream outputStream) {
if (outputStream == null) {
// call ours, not the superclass one
this.setWriter(null);
return;
}
checkAccess(this);
// Close the writer, then close the old stream, then establish the new stream with a new writer.
try {
synchronized (outputLock) {
final OutputStream oldStream = this.outputStream;
// do not close the old stream if creating the writer fails
final Writer writer = getNewWriter(outputStream);
try {
this.outputStream = outputStream;
updateWriter(outputStream, getEncoding());
super.setWriter(writer);
} finally {
safeFlush(oldStream);
safeClose(oldStream);
}
}
} catch (UnsupportedEncodingException e) {
throw new IllegalArgumentException("The specified encoding is invalid");
} catch (Exception e) {
reportError("Error opening output stream", e, ErrorManager.OPEN_FAILURE);
return;
}
}
private void updateWriter(final OutputStream newOutputStream, final String encoding) throws UnsupportedEncodingException {
final UninterruptibleOutputStream outputStream = new UninterruptibleOutputStream(newOutputStream);
super.setWriter(newOutputStream == null ? null : encoding == null ? new OutputStreamWriter(outputStream) : new OutputStreamWriter(outputStream, encoding));
private Writer getNewWriter(OutputStream newOutputStream) {
if (newOutputStream == null) return null;
final UninterruptibleOutputStream outputStream = new UninterruptibleOutputStream(new UncloseableOutputStream(newOutputStream));
final Charset charset = this.charset;
return charset == null ? new OutputStreamWriter(outputStream) : new OutputStreamWriter(outputStream, charset);
}
}
......@@ -498,10 +498,6 @@ public class SyslogHandler extends ExtHandler {
@Override
public final void doPublish(final ExtLogRecord record) {
// Don't log empty messages
if (record.getMessage() == null || record.getMessage().isEmpty()) {
return;
}
synchronized (outputLock) {
init();
if (out == null) {
......
......@@ -165,7 +165,7 @@ public class WriterHandler extends ExtHandler {
} catch (Throwable ignored) {}
}
private void safeFlush(Flushable f) {
void safeFlush(Flushable f) {
try {
if (f != null) f.flush();
} catch (Exception e) {
......
......@@ -248,6 +248,58 @@ public class PatternFormatterTests {
Assert.assertTrue(formatted.contains("CIRCULAR REFERENCE:java.lang.IllegalStateException: suppressedLevel1"));
}
@Test
public void unqualifiedHost() {
final String hostName = "logmanager.jboss.org";
final ExtLogRecord record = createLogRecord("test");
record.setHostName(hostName);
PatternFormatter formatter = new PatternFormatter("%h");
Assert.assertEquals("logmanager", formatter.format(record));
// This should still return just the first portion
formatter = new PatternFormatter("%h{2}");
Assert.assertEquals("logmanager", formatter.format(record));
// Should truncate from the beginning
formatter = new PatternFormatter("%.3h");
Assert.assertEquals("log", formatter.format(record));
// Should truncate from the end
formatter = new PatternFormatter("%.-7h");
Assert.assertEquals("manager", formatter.format(record));
}
@Test
public void qualifiedHost() {
final String hostName = "logmanager.jboss.org";
final ExtLogRecord record = createLogRecord("test");
record.setHostName(hostName);
PatternFormatter formatter = new PatternFormatter("%H");
Assert.assertEquals(hostName, formatter.format(record));
formatter = new PatternFormatter("%H{1}");
Assert.assertEquals("logmanager", formatter.format(record));
formatter = new PatternFormatter("%H{2}");
Assert.assertEquals("logmanager.jboss", formatter.format(record));
formatter = new PatternFormatter("%H{3}");
Assert.assertEquals(hostName, formatter.format(record));
formatter = new PatternFormatter("%H{4}");
Assert.assertEquals(hostName, formatter.format(record));
// Truncate from the beginning
formatter = new PatternFormatter("%.10H");
Assert.assertEquals("logmanager", formatter.format(record));
// Truncate from the end
formatter = new PatternFormatter("%.-3H");
Assert.assertEquals("org", formatter.format(record));
formatter = new PatternFormatter("%.-5H{2}");
Assert.assertEquals("jboss", formatter.format(record));
}
private void systemProperties(final String propertyPrefix) throws Exception {
final ExtLogRecord record = createLogRecord("test");
......
......@@ -182,6 +182,22 @@ public class SyslogHandlerTests {
}
@Test
public void testNullMessage() throws Exception {
// Setup the handler
handler.setSyslogType(SyslogType.RFC5424);
final ByteArrayOutputStream out = new ByteArrayOutputStream();
handler.setOutputStream(out);
final Calendar cal = getCalendar();
// Create the record
handler.setHostname("test");
ExtLogRecord record = createRecord(cal, null);
final String expectedMessage = "<14>1 2012-01-09T04:39:22.000" + calculateTimeZone(cal) + " test java " + handler.getPid() + " - - " + BOM + "null";
handler.publish(record);
Assert.assertEquals(expectedMessage, createString(out));
}
private void testMultibyteTruncation(final String part1, final String part2, final int charsToTruncate) throws Exception {
// Setup the handler
handler.setSyslogType(SyslogType.RFC5424);
......
......@@ -18,21 +18,21 @@ deleteFile client.cer
dname="CN=localhost, OU=Server Unit, O=Red Hat, L=Raleigh, S=NC, C=US"
# Create server keystore - file server-keystore.jks
keytool -genkey -v -alias server -keystore server-keystore.jks -validity 3650 -keypass testpassword -storepass testpassword -dname "${dname}"
keytool -genkey -v -alias server -keystore server-keystore.jks -keyalg RSA -validity 3650 -keypass testpassword -storepass testpassword -dname "${dname}"
# Export Server's Public Key - file server.cer
keytool -export -keystore server-keystore.jks -alias server -file server.cer -keypass testpassword -storepass testpassword
# Export Client Key Store - file client-keystore.jsk
keytool -genkey -v -alias client -keystore client-keystore.jks -validity 3650 -keypass testpassword -storepass testpassword -dname "${dname}"
keytool -genkey -v -alias client -keystore client-keystore.jks -keyalg RSA -validity 3650 -keypass testpassword -storepass testpassword -dname "${dname}"
# Exporting Client's Public Key - file client.cer
keytool -export -keystore client-keystore.jks -alias client -file client.cer -keypass testpassword -storepass testpassword
# Importing Client's Public key into server's truststore
keytool -import -v -trustcacerts -alias client -file client.cer -keystore server-keystore.jks -keypass testpassword -storepass testpassword
keytool -import -v -trustcacerts -alias client -file client.cer -keystore server-keystore.jks -keypass testpassword -storepass testpassword -noprompt
# Importing Server's Public key into client's truststore
keytool -import -v -trustcacerts -alias server -file server.cer -keystore client-keystore.jks -keypass testpassword -storepass testpassword
keytool -import -v -trustcacerts -alias server -file server.cer -keystore client-keystore.jks -keypass testpassword -storepass testpassword -noprompt
popd