Skip to content

Commit d41ccc7

Browse files
committed
Adding checks to verify that the factories are really destroyed before setting factory=null;
1 parent 8f5b015 commit d41ccc7

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

pvAccessJava/src/org/epics/ca/ClientFactory.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,18 @@ public ChannelProvider newInstance() {
7878
}
7979
}
8080

81-
public synchronized void destroySharedInstance() {
81+
public synchronized boolean destroySharedInstance() {
82+
boolean destroyed = true;
8283
if (channelProvider != null)
8384
{
84-
channelProvider.destroy();
85-
channelProvider = null;
85+
try{
86+
channelProvider.destroy();
87+
channelProvider = null;
88+
} catch (Exception ex) {
89+
destroyed = false;
90+
}
8691
}
92+
return destroyed;
8793
}
8894
}
8995

@@ -103,8 +109,10 @@ public static synchronized void stop() {
103109
if (factory != null)
104110
{
105111
ChannelProviderRegistryFactory.unregisterChannelProviderFactory(factory);
106-
factory.destroySharedInstance();
107-
factory=null;
112+
if(factory.destroySharedInstance())
113+
{
114+
factory=null;
115+
}
108116
}
109117
}
110118

pvAccessJava/src/org/epics/pvaccess/ClientFactory.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,15 @@ public ChannelProvider newInstance() {
7070
}
7171
}
7272

73-
public synchronized void destroySharedInstance() {
73+
public synchronized boolean destroySharedInstance() {
74+
boolean destroyed = true;
7475
if (context != null)
7576
{
7677
context.dispose();
78+
destroyed = context.isDestroyed();
7779
context = null;
7880
}
81+
return destroyed;
7982
}
8083
}
8184

@@ -95,8 +98,10 @@ public static synchronized void stop() {
9598
if (factory != null)
9699
{
97100
ChannelProviderRegistryFactory.unregisterChannelProviderFactory(factory);
98-
factory.destroySharedInstance();
99-
factory=null;
101+
if(factory.destroySharedInstance())
102+
{
103+
factory=null;
104+
}
100105
}
101106
}
102107
}

0 commit comments

Comments
 (0)