You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the EZIDClient class, methods such as, create, createOrUpdate, setMetadata, and delete run on a different thread. When errors happen in another thread, it only logs in a file. So this cause clients can't capture the exception. Here is a ticket to describe the issue in Metacat: NCEAS/metacat#1545
We need provide a mechanism for client to catch the exceptions even though we still keep the multi-thread feature.
The text was updated successfully, but these errors were encountered:
Here is my proposal.
First, change the class of EZIDServiceRequest to implement the Callable interface rather than Runnable interface. The call method in the Callable interface can throw an exception but the run method in the Runnable interface can't. So the method can be:
public String call() throws EZIDException {
String result = "success" ;
.......
return result;
}
The EZIDException will not be swallowed by the call method. Currently, we just log the error message in the run method if the exception raises.
In order for the client to get the thrown exception, we need give the client a Future object. Here is our current implementation of the setMetadata method in the EZIDClient class:
public void setMetadata(String identifier, HashMap<String, String> metadata) throws InterruptedException {
EZIDServiceRequest request = new EZIDServiceRequest(ezid, EZIDServiceRequest.SETMETADATA, identifier, metadata);
executor.execute(request);
}
Here is the new implementation and it returns a Future object:
The EzidException thrown by the call method will be wrapped by the ExecutionException when we call future.get(). So the client can catch the exception and re-login.
In the EZIDClient class, methods such as,
create
,createOrUpdate
,setMetadata
, anddelete
run on a different thread. When errors happen in another thread, it only logs in a file. So this cause clients can't capture the exception. Here is a ticket to describe the issue in Metacat:NCEAS/metacat#1545
We need provide a mechanism for client to catch the exceptions even though we still keep the multi-thread feature.
The text was updated successfully, but these errors were encountered: