Skip to content

Commit

Permalink
Revert "ftr: prevent eager closing of file writer upon every log
Browse files Browse the repository at this point in the history
invocation"

This reverts commit 53dc6b6 as it
caused test failures in
- org.eclipse.core.tests.internal.runtime.LogSerializationTest
- org.eclipse.equinox.p2.tests.mirror.ArtifactMirrorApplicationTest
- org.eclipse.equinox.p2.tests.mirror.NewMirrorApplicationArtifactTest

Note: pom and manifest files are left unchanged to avoid going back with
bundle versions.

Original PR: #382
Original ticket: #221
  • Loading branch information
iloveeclipse committed Oct 25, 2023
1 parent 53dc6b6 commit 60700f0
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 217 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@

@RunWith(Suite.class)
@Suite.SuiteClasses({ //
LogServiceTest.class, //
LogReaderServiceTest.class, //
LogPermissionCollectionTest.class, //
EquinoxLogWriterTest.class //
})
LogServiceTest.class, //
LogReaderServiceTest.class, //
LogPermissionCollectionTest.class //
})
public class AllLogServiceTests {
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,7 @@ public void start(BundleContext context) throws BundleException {
* @throws BundleException
*/
public void stop(BundleContext context) throws BundleException {
logWriter.close();
frameworkLogReg.unregister();
perfWriter.close();
perfLogReg.unregister();
logServiceManager.stop(context);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
* Copyright (c) 2023 Robert Bosch GmbH - https://github.com/eclipse-equinox/equinox/issues/221
*******************************************************************************/
package org.eclipse.osgi.internal.log;

Expand Down Expand Up @@ -85,9 +84,6 @@ class EquinoxLogWriter implements SynchronousLogListener, LogFilter {

/** The system property used to specify command line args should be omitted from the log */
private static final String PROP_LOG_INCLUDE_COMMAND_LINE = "eclipse.log.include.commandline"; //$NON-NLS-1$
/** The system property used to specify the log file writer should be closed eagerly */
private static final String PROP_CLOSE_LOG_FILE_EAGERLY = "eclipse.log.closeFile.eagerClose"; //$NON-NLS-1$

/** Indicates if the console messages should be printed to the console (System.out) */
private boolean consoleLog = false;
/** Indicates if the next log message is part of a new session */
Expand Down Expand Up @@ -115,15 +111,6 @@ class EquinoxLogWriter implements SynchronousLogListener, LogFilter {

private LoggerAdmin loggerAdmin = null;

/**
* Controls whether the log file should be closed eagerly upon every log
* invocation.
*
* Can be controlled by property
* {@link EquinoxLogWriter#PROP_CLOSE_LOG_FILE_EAGERLY}.
*/
private boolean closeLogFileEagerly = false;

/**
* Constructs an EclipseLog which uses the specified File to log messages to
* @param outFile a file to log messages to
Expand Down Expand Up @@ -316,8 +303,6 @@ private synchronized void log(FrameworkLogEntry logEntry) {
writeLog(0, logEntry);
writer.flush();
} catch (Exception e) {
// close log file writer upon exceptions
closeFile();
// any exceptions during logging should be caught
System.err.println("An exception occurred while writing to the platform log:");//$NON-NLS-1$
e.printStackTrace(System.err);
Expand All @@ -330,14 +315,9 @@ private synchronized void log(FrameworkLogEntry logEntry) {
} catch (Exception e2) {
System.err.println("An exception occurred while logging to the console:");//$NON-NLS-1$
e2.printStackTrace(System.err);
} finally {
// ensure that the error stream writer is closed
closeFile();
}
} finally {
if (closeLogFileEagerly) {
closeFile();
}
closeFile();
}
}

Expand Down Expand Up @@ -699,13 +679,6 @@ else if (newLogLevel.equals("INFO")) //$NON-NLS-1$

includeCommandLine = "true".equals(environmentInfo.getConfiguration(PROP_LOG_INCLUDE_COMMAND_LINE, "true")); //$NON-NLS-1$//$NON-NLS-2$
applyLogLevel();

String newCloseLogFileEagerlyValue = environmentInfo.getConfiguration(PROP_CLOSE_LOG_FILE_EAGERLY);
if (newCloseLogFileEagerlyValue != null) {
if (Boolean.valueOf(newCloseLogFileEagerlyValue) == Boolean.TRUE) {
closeLogFileEagerly = true;
}
}
}

void applyLogLevel() {
Expand Down

0 comments on commit 60700f0

Please sign in to comment.