Skip to content

Commit 1c723df

Browse files
authored
Merge pull request #89 from juanfem/issue_88
Setting factory to null after destroying it, so that the next time th…
2 parents c7343f0 + d41ccc7 commit 1c723df

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

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

Lines changed: 13 additions & 4 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,7 +109,10 @@ public static synchronized void stop() {
103109
if (factory != null)
104110
{
105111
ChannelProviderRegistryFactory.unregisterChannelProviderFactory(factory);
106-
factory.destroySharedInstance();
112+
if(factory.destroySharedInstance())
113+
{
114+
factory=null;
115+
}
107116
}
108117
}
109118

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

Lines changed: 8 additions & 2 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,7 +98,10 @@ public static synchronized void stop() {
9598
if (factory != null)
9699
{
97100
ChannelProviderRegistryFactory.unregisterChannelProviderFactory(factory);
98-
factory.destroySharedInstance();
101+
if(factory.destroySharedInstance())
102+
{
103+
factory=null;
104+
}
99105
}
100106
}
101107
}

0 commit comments

Comments
 (0)