Uploaded image for project: 'EJB Client Library (AS7+)'
  1. EJB Client Library (AS7+)
  2. EJBCLIENT-386

DiscoveryEJBClientInterceptor.getBlacklist check is incorrect

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 4.1.0.Final, 4.0.36.Final
    • 4.0.35.Final
    • None

    Description

      EJBCLIENT-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 :

       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     } 

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: