Uploaded image for project: 'JBoss Enterprise Application Platform'
  1. JBoss Enterprise Application Platform
  2. JBEAP-20340

[GSS](7.3.z) EJBCLIENT-386 - discovery.blacklist.timeout getBlacklist check is incorrect

XMLWordPrintable

      JBEAP-18565EJBCLIENT-361  , the blacklist timeout check is backwards in the getBlacklist method.  The isBlackListed is correct, it removes from the blacklist if delta > BLACKLIST_TIMEOUT , whereas getBlacklist is removing if delta < BLACKLIST_TIMEOUT.

      This bug causes destinations that get blacklisted to be removed from the blacklist before the timeout resulting in those requests having to be retried on another node.  It also could result in a backlisted destination from not being added back into the available destinations if one gets blacklisted and the next time it is checked that the blacklist timeout has passed, that destination would then never be removed from the blacklist.

       

       74 public final class DiscoveryEJBClientInterceptor implements EJBClientInterceptor {
      
       91     private static final long BLACKLIST_TIMEOUT =
       92             AccessController.doPrivileged((PrivilegedAction<Long>) () -> {
       93                 String val = System.getProperty("org.jboss.ejb.client.discovery.blacklist.timeout");
       94                 try {
       95                     return TimeUnit.MILLISECONDS.toNanos(Long.valueOf(val));
       96                 } catch (NumberFormatException e) {
       97                     return TimeUnit.MILLISECONDS.toNanos(5000L);
       98                 }
       99             });
      
      311     static boolean isBlackListed(AbstractInvocationContext context, URI destination) {
      312         final Set<URI> invocationBlacklist = context.getAttachment(BL_KEY);
      313         if (invocationBlacklist != null && invocationBlacklist.contains(destination)) {
      314             return true;
      315         }
      316         if (!blacklist.containsKey(destination)) {
      317             return false;
      318         }
      319         final long blacklistedTimestamp = blacklist.get(destination);
      320         final long delta = System.nanoTime() - blacklistedTimestamp;
      321         if (delta < BLACKLIST_TIMEOUT) {
      322             return true;
      323         } else {
      324             blacklist.remove(destination);
      325             return false;
      326         }
      327     }
      328 
      329     private static Set<URI> getBlacklist(){
      330         blacklist.entrySet().removeIf(e ->
      331         {
      332             final long delta = System.nanoTime() - e.getValue();
      333             return delta < BLACKLIST_TIMEOUT;
      334         });
      335         return blacklist.keySet();
      336     } 

              rhn-support-bmaxwell Brad Maxwell
              rhn-support-bmaxwell Brad Maxwell
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Created:
                Updated:
                Resolved: