avoid class cast when Z server return a Close instead of a SearchResponse (timeout)
This commit is contained in:
parent
1a0ff7d6c8
commit
7bcc85b223
3 changed files with 41 additions and 34 deletions
|
@ -1,6 +1,6 @@
|
|||
group = org.xbib
|
||||
name = z3950
|
||||
version = 2.3.1
|
||||
version = 2.3.2
|
||||
|
||||
gradle.wrapper.version = 6.6.1
|
||||
netty.version = 4.1.65.Final
|
||||
|
|
|
@ -120,19 +120,20 @@ public class AbstractOperation<IN extends ASN1Any, OUT extends ASN1Any> {
|
|||
if (ber.getTagType() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
|
||||
throw new ASN1Exception("bad BER encoding: choice not matched");
|
||||
}
|
||||
try {
|
||||
switch (ber.getTag()) {
|
||||
case 20:
|
||||
return (IN)new InitializeRequest(ber, false);
|
||||
return (IN) new InitializeRequest(ber, false);
|
||||
case 21:
|
||||
return (IN)new InitializeResponse(ber, false);
|
||||
return (IN) new InitializeResponse(ber, false);
|
||||
case 22:
|
||||
return (IN)new SearchRequest(ber, false);
|
||||
return (IN) new SearchRequest(ber, false);
|
||||
case 23:
|
||||
return (IN)new SearchResponse(ber, false);
|
||||
return (IN) new SearchResponse(ber, false);
|
||||
case 24:
|
||||
return (IN)new PresentRequest(ber, false);
|
||||
return (IN) new PresentRequest(ber, false);
|
||||
case 25:
|
||||
return (IN)new PresentResponse(ber, false);
|
||||
return (IN) new PresentResponse(ber, false);
|
||||
// 26 new DeleteResultSetRequest(ber, false);
|
||||
// 27 new DeleteResultSetResponse(ber, false);
|
||||
// 28 new AccessControlRequest(ber, false);
|
||||
|
@ -154,6 +155,10 @@ public class AbstractOperation<IN extends ASN1Any, OUT extends ASN1Any> {
|
|||
case 48:
|
||||
return (IN) new Close(ber, false);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// class cast exception if Close is returned, ignore
|
||||
return null;
|
||||
}
|
||||
throw new ASN1Exception("bad BER encoding: choice not matched");
|
||||
}
|
||||
|
||||
|
|
|
@ -133,6 +133,8 @@ public class SearchOperation extends AbstractOperation<SearchResponse, SearchReq
|
|||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
logger.log(Level.WARNING, "no search response returned for host " + host + " " + databases);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// add host in IOException message
|
||||
|
|
Loading…
Reference in a new issue