Skip to content
Commits on Source (7)
jboss-logmanager (2.1.13-1) unstable; urgency=medium
* New upstream version 2.1.13.
* Switch to debhelper-compat = 12.
* Declare compliance with Debian Policy 4.4.0.
-- Markus Koschany <apo@debian.org> Fri, 19 Jul 2019 01:14:16 +0200
jboss-logmanager (2.1.7-1) unstable; urgency=medium
* New upstream version 2.1.7.
......
......@@ -5,7 +5,7 @@ Maintainer: Debian Java Maintainers <pkg-java-maintainers@lists.alioth.debian.or
Uploaders:
Markus Koschany <apo@debian.org>
Build-Depends:
debhelper (>= 11),
debhelper-compat (= 12),
default-jdk,
default-jdk-doc,
junit4,
......@@ -18,7 +18,7 @@ Build-Depends:
libmaven-source-plugin-java,
libwildfly-common-java,
maven-debian-helper (>= 1.5)
Standards-Version: 4.3.0
Standards-Version: 4.4.0
Vcs-Git: https://salsa.debian.org/java-team/jboss-logmanager.git
Vcs-Browser: https://salsa.debian.org/java-team/jboss-logmanager
Homepage: https://github.com/jboss-logging/jboss-logmanager
......
......@@ -3,11 +3,11 @@ Upstream-Name: JBoss Log Manager
Source: https://github.com/jboss-logging/jboss-logmanager
Files: *
Copyright: 2014-2018, Red Hat, Inc.
Copyright: 2014-2019, Red Hat, Inc.
License: Apache-2.0
Files: debian/*
Copyright: 2015-2018, Markus Koschany <apo@debian.org>
Copyright: 2015-2019, Markus Koschany <apo@debian.org>
License: Apache-2.0
License: Apache-2.0
......
......@@ -2,4 +2,3 @@
%:
dh $@
......@@ -28,12 +28,12 @@
<groupId>org.jboss.logmanager</groupId>
<artifactId>jboss-logmanager</artifactId>
<packaging>jar</packaging>
<version>2.1.7.Final</version>
<version>2.1.13.Final</version>
<parent>
<groupId>org.jboss</groupId>
<artifactId>jboss-parent</artifactId>
<version>26</version>
<version>34</version>
</parent>
<licenses>
......@@ -47,10 +47,10 @@
<properties>
<!-- Dependency versions -->
<version.javax.json>1.0</version.javax.json>
<version.org.byteman>4.0.4</version.org.byteman>
<version.org.byteman>4.0.6</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.org.jboss.modules.jboss-modules>1.9.1.Final</version.org.jboss.modules.jboss-modules>
<version.org.wildfly.common.wildfly-common>1.5.1.Final</version.org.wildfly.common.wildfly-common>
<version.junit.junit>4.12</version.junit.junit>
<!-- Test properties -->
......@@ -72,6 +72,7 @@
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.wildfly.common</groupId>
<artifactId>wildfly-common</artifactId>
......@@ -171,7 +172,6 @@
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0-jboss-1</version>
<executions>
<execution>
<id>default-compile</id>
......@@ -286,7 +286,7 @@
<dependency>
<groupId>biz.aQute.bnd</groupId>
<artifactId>biz.aQute.bndlib</artifactId>
<version>3.5.0</version>
<version>4.2.0</version>
</dependency>
</dependencies>
<configuration>
......
......@@ -42,7 +42,7 @@ import java.util.logging.LoggingPermission;
/**
* A logging context, for producing isolated logging environments.
*/
@SuppressWarnings("unused")
@SuppressWarnings({"unused", "WeakerAccess"})
public final class LogContext implements Protectable, AutoCloseable {
private static final LogContext SYSTEM_CONTEXT = new LogContext(false);
......@@ -318,6 +318,15 @@ public final class LogContext implements Protectable, AutoCloseable {
logContextSelector = newSelector;
}
/**
* Returns the currently set log context selector.
*
* @return the log context selector
*/
public static LogContextSelector getLogContextSelector() {
return logContextSelector;
}
@Override
public void protect(Object protectionKey) throws SecurityException {
if (protectKeyUpdater.compareAndSet(this, null, protectionKey)) {
......
......@@ -157,9 +157,7 @@ public class PeriodicSizeRotatingFileHandler extends PeriodicRotatingFileHandler
suffixRotator.rotate(getErrorManager(), file.toPath(), suffix, maxBackupIndex);
}
}
super.setFile(file);
if (outputStream != null)
outputStream.currentSize = file == null ? 0L : file.length();
setFileInternal(file);
}
}
......@@ -224,13 +222,19 @@ public class PeriodicSizeRotatingFileHandler extends PeriodicRotatingFileHandler
return;
}
// close the old file.
setFile(null);
setFileInternal(null);
getSuffixRotator().rotate(getErrorManager(), file.toPath(), getNextSuffix(), maxBackupIndex);
// start with new file.
setFile(file);
setFileInternal(file);
} catch (IOException e) {
reportError("Unable to rotate log file", e, ErrorManager.OPEN_FAILURE);
}
}
}
private void setFileInternal(final File file) throws FileNotFoundException {
super.setFile(file);
if (outputStream != null)
outputStream.currentSize = file == null ? 0L : file.length();
}
}
......@@ -141,9 +141,7 @@ public class SizeRotatingFileHandler extends FileHandler {
if (rotateOnBoot && maxBackupIndex > 0 && file != null && file.exists() && file.length() > 0L) {
suffixRotator.rotate(getErrorManager(), file.toPath(), maxBackupIndex);
}
super.setFile(file);
if (outputStream != null)
outputStream.currentSize = file == null ? 0L : file.length();
setFileInternal(file);
}
}
......@@ -244,13 +242,19 @@ public class SizeRotatingFileHandler extends FileHandler {
return;
}
// close the old file.
setFile(null);
setFileInternal(null);
suffixRotator.rotate(getErrorManager(), file.toPath(), maxBackupIndex);
// start with new file.
setFile(file);
setFileInternal(file);
} catch (IOException e) {
reportError("Unable to rotate log file", e, ErrorManager.OPEN_FAILURE);
}
}
}
private void setFileInternal(final File file) throws FileNotFoundException {
super.setFile(file);
if (outputStream != null)
outputStream.currentSize = file == null ? 0L : file.length();
}
}
......@@ -155,6 +155,8 @@ class SuffixRotator {
if (compressionType == CompressionType.GZIP) {
try {
archiveGzip(source, target);
// Delete the file after it's archived to behave like a file move or rename
Files.delete(source);
} catch (Exception e) {
errorManager.error(String.format("Failed to compress %s to %s. Compressed file may be left on the " +
"filesystem corrupted.", source, target), e, ErrorManager.WRITE_FAILURE);
......@@ -162,6 +164,8 @@ class SuffixRotator {
} else if (compressionType == CompressionType.ZIP) {
try {
archiveZip(source, target);
// Delete the file after it's archived to behave like a file move or rename
Files.delete(source);
} catch (Exception e) {
errorManager.error(String.format("Failed to compress %s to %s. Compressed file may be left on the " +
"filesystem corrupted.", source, target), e, ErrorManager.WRITE_FAILURE);
......
......@@ -29,6 +29,8 @@ import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.zip.GZIPInputStream;
......@@ -152,7 +154,7 @@ public class AbstractHandlerTest {
* @throws IOException if an error occurs reading the zip file
*/
static void validateZipContents(final Path path, final String expectedFileName, final String expectedContains) throws IOException {
try (final FileSystem zipFs = FileSystems.newFileSystem(URI.create("jar:" + path.toUri().toASCIIString()), Collections.singletonMap("create", "true"))) {
try (final FileSystem zipFs = FileSystems.newFileSystem(URI.create("jar:" + path.toUri().toASCIIString()), Collections.singletonMap("create", "true"))) {
final Path file = zipFs.getPath(zipFs.getSeparator(), expectedFileName);
Assert.assertTrue(String.format("Expected file %s not found.", expectedFileName), Files.exists(file));
final List<String> lines = Files.readAllLines(file, StandardCharsets.UTF_8);
......@@ -160,4 +162,62 @@ public class AbstractHandlerTest {
Assert.assertTrue(String.format("ZIP file %s missing contents: %s", path, expectedContains), lines.get(0).contains(expectedContains));
}
}
static void compareArchiveContents(final Path archive1, final Path archive2, final String expectedFileName) throws IOException {
Collection<String> lines1 = Collections.emptyList();
Collection<String> lines2 = Collections.emptyList();
if (archive1.getFileName().toString().endsWith(".zip")) {
lines1 = readAllLinesFromZip(archive1, expectedFileName);
lines2 = readAllLinesFromZip(archive2, expectedFileName);
} else if (archive1.getFileName().toString().endsWith(".gz")) {
lines1 = readAllLinesFromGzip(archive1, expectedFileName);
lines2 = readAllLinesFromGzip(archive2, expectedFileName);
} else {
Assert.fail(String.format("Files %s and %s are not archives.", archive1, archive2));
}
// Assert the contents aren't empty
Assert.assertFalse(String.format("Archive %s contained no data", archive1), lines1.isEmpty());
Assert.assertFalse(String.format("Archive %s contained no data", archive2), lines2.isEmpty());
final Collection<String> copy1 = new ArrayList<>(lines1);
final Collection<String> copy2 = new ArrayList<>(lines2);
boolean altered = copy1.removeAll(copy2);
if (copy1.size() == 0) {
Assert.fail(String.format("The contents of %s and %s are identical and should not be", archive1, archive2));
} else if (altered) {
final StringBuilder msg = new StringBuilder(1024)
.append("The following contents are in both ")
.append(archive1)
.append(" and ")
.append(archive2);
// Find the identical lines and report
for (String line : lines1) {
if (lines2.contains(line)) {
msg.append(System.lineSeparator()).append(line);
}
}
Assert.fail(msg.toString());
}
}
private static Collection<String> readAllLinesFromZip(final Path path, final String expectedFileName) throws IOException {
try (final FileSystem zipFs = FileSystems.newFileSystem(URI.create("jar:" + path.toUri().toASCIIString()), Collections.singletonMap("create", "true"))) {
final Path file = zipFs.getPath(zipFs.getSeparator(), expectedFileName);
Assert.assertTrue(String.format("Expected file %s not found.", expectedFileName), Files.exists(file));
return Files.readAllLines(file, StandardCharsets.UTF_8);
}
}
private static Collection<String> readAllLinesFromGzip(final Path path, final String expectedFileName) throws IOException {
final Collection<String> lines = new ArrayList<>();
try (BufferedReader reader = new BufferedReader(new InputStreamReader(new GZIPInputStream(Files.newInputStream(path))))) {
String line;
while ((line = reader.readLine()) != null) {
lines.add(line);
}
}
return lines;
}
}
......@@ -57,6 +57,8 @@ public class PeriodicRotatingFileHandlerTests extends AbstractHandlerTest {
// Create the handler
handler = new PeriodicRotatingFileHandler(logFile.toFile(), rotateFormatter.toPattern(), false);
handler.setFormatter(FORMATTER);
// Set append to true to ensure the rotated file is overwritten
handler.setAppend(true);
}
@After
......@@ -108,6 +110,8 @@ public class PeriodicRotatingFileHandlerTests extends AbstractHandlerTest {
final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
final int currentDay = cal.get(Calendar.DAY_OF_MONTH);
final int nextDay = currentDay + 1;
// Set to false for this specific test
handler.setAppend(false);
final String currentDate = sdf.format(cal.getTime());
......@@ -225,5 +229,6 @@ public class PeriodicRotatingFileHandlerTests extends AbstractHandlerTest {
} else {
Assert.fail("Unknown archive suffix: " + archiveSuffix);
}
compareArchiveContents(rotated1, rotated2, logFile.getFileName().toString());
}
}
......@@ -185,22 +185,26 @@ public class PeriodicSizeRotatingFileHandlerTests extends AbstractHandlerTest {
@Test
public void testArchiveRotateGzip() throws Exception {
testArchiveRotate(".yyyy-MM-dd", ".gz");
testArchiveRotate(".yyyy-MM-dd", ".gz", false);
testArchiveRotate(".yyyy-MM-dd", ".gz", true);
}
@Test
public void testArchiveRotateZip() throws Exception {
testArchiveRotate(".yyyy-MM-dd", ".zip");
testArchiveRotate(".yyyy-MM-dd", ".zip", false);
testArchiveRotate(".yyyy-MM-dd", ".zip", true);
}
@Test
public void testArchiveRotateSizeOnlyGzip() throws Exception {
testArchiveRotate(null, ".gz");
testArchiveRotate(null, ".gz", false);
testArchiveRotate(null, ".gz", true);
}
@Test
public void testArchiveRotateSizeOnlyZip() throws Exception {
testArchiveRotate(null,".zip");
testArchiveRotate(null,".zip", false);
testArchiveRotate(null,".zip", true);
}
@Test
......@@ -235,14 +239,17 @@ public class PeriodicSizeRotatingFileHandlerTests extends AbstractHandlerTest {
Assert.assertTrue("Expected the last line to end with 99: " + lastLine, lastLine.endsWith("99"));
}
private void testArchiveRotate(final String dateSuffix, final String archiveSuffix) throws Exception {
private void testArchiveRotate(final String dateSuffix, final String archiveSuffix, final boolean rotateOnBoot) throws Exception {
final String currentDate = dateSuffix == null ? "" : LocalDate.now().format(DateTimeFormatter.ofPattern(dateSuffix));
PeriodicSizeRotatingFileHandler handler = new PeriodicSizeRotatingFileHandler();
configureHandlerDefaults(handler);
handler.setRotateSize(1024L);
handler.setMaxBackupIndex(2);
handler.setFile(logFile);
handler.setRotateOnBoot(rotateOnBoot);
handler.setSuffix((dateSuffix == null ? "" : dateSuffix) + archiveSuffix);
// Set append to true to ensure the rotated file is overwritten
handler.setAppend(true);
// Allow a few rotates
for (int i = 0; i < 100; i++) {
......@@ -269,6 +276,7 @@ public class PeriodicSizeRotatingFileHandlerTests extends AbstractHandlerTest {
} else {
Assert.fail("Unknown archive suffix: " + archiveSuffix);
}
compareArchiveContents(path1, path2, logFile.getName());
// Clean up files
Files.deleteIfExists(path1);
......
......@@ -157,12 +157,14 @@ public class SizeRotatingFileHandlerTests extends AbstractHandlerTest {
@Test
public void testArchiveRotateGzip() throws Exception {
testArchiveRotate(".gz");
testArchiveRotate(".gz", false);
testArchiveRotate(".gz", true);
}
@Test
public void testArchiveRotateZip() throws Exception {
testArchiveRotate(".zip");
testArchiveRotate(".zip", false);
testArchiveRotate(".zip", true);
}
/**
......@@ -201,13 +203,16 @@ public class SizeRotatingFileHandlerTests extends AbstractHandlerTest {
Assert.assertTrue("Expected the last line to end with 99: " + lastLine, lastLine.endsWith("99"));
}
private void testArchiveRotate(final String archiveSuffix) throws Exception {
private void testArchiveRotate(final String archiveSuffix, final boolean rotateOnBoot) throws Exception {
final SizeRotatingFileHandler handler = new SizeRotatingFileHandler();
configureHandlerDefaults(handler);
handler.setRotateSize(1024L);
handler.setMaxBackupIndex(2);
handler.setFile(logFile);
handler.setSuffix(archiveSuffix);
handler.setRotateOnBoot(rotateOnBoot);
// Set append to true to ensure the rotated file is overwritten
handler.setAppend(true);
// Allow a few rotates
for (int i = 0; i < 100; i++) {
......@@ -235,6 +240,8 @@ public class SizeRotatingFileHandlerTests extends AbstractHandlerTest {
Assert.fail("Unknown archive suffix: " + archiveSuffix);
}
compareArchiveContents(path1, path2, logFile.getName());
// Clean up files
Files.deleteIfExists(path1);
Files.deleteIfExists(path2);
......