Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2014-07-25 07:28:15 -0400
committerUwe Stieber2014-07-25 07:28:15 -0400
commit657ebd31430767eb9c4abf6df2ed37155b77ee77 (patch)
tree0e9f8cb79ee25ae3ddc082290471b67019ba9d3c
parent3856b1981d7bcf9c1fa164805b00497543ee0708 (diff)
downloadorg.eclipse.tcf-657ebd31430767eb9c4abf6df2ed37155b77ee77.tar.gz
org.eclipse.tcf-657ebd31430767eb9c4abf6df2ed37155b77ee77.tar.xz
org.eclipse.tcf-657ebd31430767eb9c4abf6df2ed37155b77ee77.zip
Target Explorer: Channel communication log misses close channel event if more than one channel to the same target gets closed
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/events/ChannelEvent.java1
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/ChannelManager.java25
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/activator/CoreBundleActivator.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/LogManager.java15
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/listener/ChannelTraceListener.java13
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/listener/EventListener.java4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/nls/Messages.java1
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/nls/Messages.properties1
8 files changed, 47 insertions, 15 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/events/ChannelEvent.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/events/ChannelEvent.java
index f0199badb..746eed9a3 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/events/ChannelEvent.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/events/ChannelEvent.java
@@ -24,6 +24,7 @@ public final class ChannelEvent extends EventObject {
public static final String TYPE_OPEN = "open"; //$NON-NLS-1$
public static final String TYPE_CLOSE = "close"; //$NON-NLS-1$
public static final String TYPE_MARK = "mark"; //$NON-NLS-1$
+ public static final String TYPE_CLOSE_WRITER = "closeWriter"; //$NON-NLS-1$
// The channel
private IChannel channel;
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/ChannelManager.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/ChannelManager.java
index b723c6253..70e8cfd52 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/ChannelManager.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/ChannelManager.java
@@ -467,6 +467,31 @@ public class ChannelManager extends PlatformObject implements IChannelManager {
// Log closed channels
ChannelEvent event = new ChannelEvent(ChannelManager.this, channel, ChannelEvent.TYPE_CLOSE, null);
EventManager.getInstance().fireEvent(event);
+
+ // If there is no remaining shared or private channel to the target,
+ // also close the log writer which is shared by all channels to the same target.
+ Runnable runnable = new Runnable() {
+ @Override
+ public void run() {
+ boolean closeWriter = internalGetChannel(peer) == null;
+ if (closeWriter) {
+ for (IChannel c : forcedChannels) {
+ if (id.equals(c.getRemotePeer().getID()) && c.getState() != IChannel.STATE_CLOSED) {
+ closeWriter = false;
+ break;
+ }
+ }
+
+ if (closeWriter) {
+ ChannelEvent event = new ChannelEvent(ChannelManager.this, channel, ChannelEvent.TYPE_CLOSE_WRITER, null);
+ EventManager.getInstance().fireEvent(event);
+ }
+ }
+ }
+ };
+
+ if (Protocol.isDispatchThread()) runnable.run();
+ else Protocol.invokeLater(runnable);
}
};
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/activator/CoreBundleActivator.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/activator/CoreBundleActivator.java
index a47b9293d..c375268ec 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/activator/CoreBundleActivator.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/activator/CoreBundleActivator.java
@@ -12,6 +12,7 @@ package org.eclipse.tcf.te.tcf.log.core.activator;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.tcf.te.runtime.preferences.ScopedEclipsePreferences;
import org.eclipse.tcf.te.runtime.tracing.TraceHandler;
+import org.eclipse.tcf.te.tcf.log.core.internal.LogManager;
import org.osgi.framework.BundleContext;
/**
@@ -83,6 +84,7 @@ public class CoreBundleActivator extends Plugin {
plugin = null;
scopedPreferences = null;
traceHandler = null;
+ LogManager.getInstance().dispose();
super.stop(context);
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/LogManager.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/LogManager.java
index 77f332df1..4a18739f7 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/LogManager.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/LogManager.java
@@ -14,7 +14,6 @@ import java.io.FileWriter;
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
-import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@@ -78,21 +77,13 @@ public final class LogManager {
* Dispose the log manager instance.
*/
public void dispose() {
- String message = NLS.bind(Messages.LogManager_dispose_message,
- DATE_FORMAT.format(new Date(System.currentTimeMillis())));
+ // Close all still open file writer instances
for (FileWriter writer : fileWriterMap.values()) {
try {
- writer.write(message);
- writer.write("\n"); //$NON-NLS-1$
+ writer.flush();
+ writer.close();
} catch (IOException e) {
/* ignored on purpose */
- } finally {
- try {
- writer.flush();
- writer.close();
- } catch (IOException e) {
- /* ignored on purpose */
- }
}
}
fileWriterMap.clear();
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/listener/ChannelTraceListener.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/listener/ChannelTraceListener.java
index fe1365739..7d58706f0 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/listener/ChannelTraceListener.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/listener/ChannelTraceListener.java
@@ -87,7 +87,18 @@ public class ChannelTraceListener implements TraceListener {
error
});
- LogManager.getInstance().closeWriter(channel, message);
+ // Get the file writer
+ FileWriter writer = LogManager.getInstance().getWriter(channel);
+ if (writer != null) {
+ try {
+ writer.write(message);
+ writer.write("\n"); //$NON-NLS-1$
+ writer.flush();
+ } catch (IOException e) {
+ /* ignored on purpose */
+ }
+ }
+
LogManager.getInstance().monitor(channel, MonitorEvent.Type.CLOSE, new MonitorEvent.Message('F', message));
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/listener/EventListener.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/listener/EventListener.java
index 92fb36c10..190a16df5 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/listener/EventListener.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/listener/EventListener.java
@@ -18,6 +18,7 @@ import org.eclipse.tcf.protocol.Protocol;
import org.eclipse.tcf.te.runtime.interfaces.events.IEventFireDelegate;
import org.eclipse.tcf.te.runtime.interfaces.events.IEventListener;
import org.eclipse.tcf.te.tcf.core.events.ChannelEvent;
+import org.eclipse.tcf.te.tcf.log.core.internal.LogManager;
/**
* Channel event listener.
@@ -60,6 +61,9 @@ public final class EventListener extends PlatformObject implements IEventListene
else if (ChannelEvent.TYPE_MARK.equals(type)) {
ChannelTraceListenerManager.getInstance().onMark(channel, message);
}
+ else if (ChannelEvent.TYPE_CLOSE_WRITER.equals(type)) {
+ LogManager.getInstance().closeWriter(channel, message);
+ }
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/nls/Messages.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/nls/Messages.java
index c734866c6..9adf534fa 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/nls/Messages.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/nls/Messages.java
@@ -35,6 +35,5 @@ public class Messages extends NLS {
public static String ChannelTraceListener_channelClosed_message;
public static String ChannelTraceListener_channelMark_message;
- public static String LogManager_dispose_message;
public static String LogManager_error_renameFailed;
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/nls/Messages.properties b/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/nls/Messages.properties
index bf8e3c507..669844a48 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/nls/Messages.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/nls/Messages.properties
@@ -14,5 +14,4 @@ ChannelTraceListener_channelOpened_message=# {0}: Opened channel {1} {2}
ChannelTraceListener_channelClosed_message=# {0}: Closed channel {1} (error={2})
ChannelTraceListener_channelMark_message=# {0}: Channel {1}: {2}
-LogManager_dispose_message=# {0}: Closed session
LogManager_error_renameFailed=Failed to rename file while cycling the log files.\n\nFrom: {0}\nTo: {1}

Back to the top