Skip to content

Commit b3af14f

Browse files
committed
Formatting of exception for read-only or other server error
1 parent 66f4b51 commit b3af14f

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

core/pva/src/main/java/org/epics/pva/client/PutRequest.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,17 @@ public void handleResponse(final ByteBuffer buffer) throws Exception
151151
fail(new Exception("Incomplete Put Response"));
152152
final int request_id = buffer.getInt();
153153
final byte subcmd = buffer.get();
154-
PVAStatus status = PVAStatus.decode(buffer);
154+
final PVAStatus status = PVAStatus.decode(buffer);
155155
if (! status.isSuccess())
156-
fail(new Exception(channel + " Put Response for " + request + ": " + status));
156+
{
157+
// Server reported an error with text like "Put not permitted"
158+
// for EPICS 7.0.6 QSRV.
159+
// Channel access similarly provided an Exception with text
160+
// "No write access rights granted."
161+
// Not trying to parse the message; passing it up with added
162+
// channel name and request info.
163+
fail(new Exception(channel + " Write for '" + channel.getName() + "' " + request + " failed with " + status));
164+
}
157165

158166
if (subcmd == PVAHeader.CMD_SUB_INIT)
159167
{

core/pva/src/test/java/org/epics/pva/client/ClientDemo.java

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,23 @@ public void testGet() throws Exception
9494
final PVAChannel ch2 = pva.getChannel("saw", listener);
9595
CompletableFuture.allOf(ch1.connect(), ch2.connect()).get(5, TimeUnit.SECONDS);
9696

97+
System.out.println("Connected.. Stop IOC in next 10 seconds to test disconnect");
98+
TimeUnit.SECONDS.sleep(10);
99+
97100
// Get data
98-
Future<PVAStructure> data = ch1.read("");
99-
System.out.println(ch1.getName() + " = " + data.get());
101+
try
102+
{
103+
Future<PVAStructure> data = ch1.read("");
104+
System.out.println(ch1.getName() + " = " + data.get());
100105

101-
data = ch2.read("");
102-
System.out.println(ch2.getName() + " = " + data.get());
106+
data = ch2.read("");
107+
System.out.println(ch2.getName() + " = " + data.get());
108+
}
109+
catch (Exception ex)
110+
{
111+
System.out.println("Read failed");
112+
ex.printStackTrace();
113+
}
103114

104115
// Close channels
105116
ch2.close();
@@ -264,7 +275,7 @@ public void testStatic() throws Exception
264275
}
265276

266277
/** Write ('put') test
267-
*
278+
*
268279
* Includes a pause to allow manual stopping of the server.
269280
*
270281
* May be used with read-only access security on IOC

0 commit comments

Comments
 (0)