Пример #1
0
 private static <K, V> V get(LoadingCache<K, V> cache, K key) {
   try {
     return cache.get(key);
   } catch (ExecutionException | UncheckedExecutionException | ExecutionError e) {
     throw Throwables.propagate(e.getCause());
   }
 }
Пример #2
0
 public CodeView getCode(String id) {
   try {
     return cache.get(id + DELIMITER + CashregisterSession.get().getLocale().getLanguage());
   } catch (ExecutionException e) {
     throw new WicketRuntimeException(e);
   }
 }
Пример #3
0
        @Override
        protected List<DynamicProperty> create() {
          List<DynamicProperty> properties = new ArrayList<DynamicProperty>();

          for (ObjectType type : getTypes()) {
            if (type.getObjectClass() == null) {
              continue;
            }

            String beanProperty = type.getJavaBeanProperty();

            if (ObjectUtils.isBlank(beanProperty)) {
              continue;
            }

            try {
              properties.add(
                  new DynamicProperty(type, beanProperty, beanPropertyIndexes.get(beanProperty)));

            } catch (Exception error) {
              // Failed introspection so probably not a valid bean
              // property.
            }
          }

          return ImmutableList.copyOf(properties);
        }
Пример #4
0
 /**
  * Makes sure that name is a valid repository name and creates a new RepositoryName using it.
  *
  * @throws LabelSyntaxException if the name is invalid
  */
 public static RepositoryName create(String name) throws LabelSyntaxException {
   try {
     return repositoryNameCache.get(name);
   } catch (ExecutionException e) {
     Throwables.propagateIfInstanceOf(e.getCause(), LabelSyntaxException.class);
     throw new IllegalStateException("Failed to create RepositoryName from " + name, e);
   }
 }
 /**
  * Implemented as specified in {@link QuantumStrategy}.
  *
  * @see QuantumStrategy#quantize(double)
  */
 @Override
 public int quantize(double value) throws QuantizationException {
   try {
     return values.get(getMiddleRange(value));
   } catch (ExecutionException e) {
     throw new QuantizationException(e);
   }
 }
 @Override
 public PEXSubject get(String identifier) {
   try {
     return subjectCache.get(identifier);
   } catch (ExecutionException e) {
     throw new RuntimeException(e);
   }
 }
 /**
  * Returns the Client for the {@link TaskRepository}.
  *
  * @param repository the {@link TaskRepository} object
  * @return the client Object
  * @throws CoreException
  */
 public BugzillaRestClient getClient(TaskRepository repository) throws CoreException {
   try {
     return clientCache.get(new RepositoryKey(repository));
   } catch (ExecutionException e) {
     throw new CoreException(
         new Status(IStatus.ERROR, BugzillaRestCore.ID_PLUGIN, "TaskRepositoryManager is null"));
   }
 }
Пример #8
0
 private static Label deserializeLabel(String labelName) throws PackageDeserializationException {
   try {
     return labelCache.get(labelName);
   } catch (ExecutionException e) {
     Throwables.propagateIfInstanceOf(e.getCause(), PackageDeserializationException.class);
     throw new IllegalStateException("Failed to decode label: " + labelName, e);
   }
 }
 public BookDTO findBookInfo(String bookId) {
   try {
     return bookInfoCache.get(bookId);
   } catch (ExecutionException e) {
     logger.error("failed to get book info for bookId : {}.", bookId);
     throw new RuntimeException("Failed to get book Info for " + bookId);
   }
 }
 public UserInfo loadUserInfo(final PendingOIDCAuthenticationToken token) {
   try {
     return cache.get(token);
   } catch (UncheckedExecutionException | ExecutionException e) {
     logger.warn("Couldn't load User Info from token: " + e.getMessage());
     return null;
   }
 }
 @Override
 public LRepository getDefaultRepository() throws InterruptedException, RepositoryException {
   try {
     return repositories.get(RepoAndTableUtil.DEFAULT_REPOSITORY);
   } catch (ExecutionException e) {
     throw new RuntimeException(e);
   }
 }
Пример #12
0
 TopLevelItem get(LazyTopLevelItem.Key key) {
   try {
     return cache.get(key);
   } catch (ExecutionException ex) {
     Logger.getLogger(TopLevelItemsCache.class.getName()).log(Level.SEVERE, null, ex);
     return null;
   }
 }
Пример #13
0
 TopLevelItem get(LazyTopLevelItem.Key key) {
   try {
     return cache.get(key);
   } catch (ExecutionException ex) {
     LoggerFactory.getLogger(TopLevelItemsCache.class.getName())
         .error("Error when retrieving item from cache", ex);
     return null;
   }
 }
Пример #14
0
 private CompiledTemplate getFromCache(
     LoadingCache<TemplateSource, CompiledTemplate> compiledTemplateCache,
     TemplateSource templateSource) {
   try {
     return compiledTemplateCache.get(templateSource);
   } catch (ExecutionException | UncheckedExecutionException e) {
     throw uncheck(toException(e.getCause()));
   }
 }
 @Override
 public LRepository getRepository(String repositoryName)
     throws InterruptedException, RepositoryException {
   try {
     return repositories.get(repositoryName);
   } catch (ExecutionException e) {
     throw new RuntimeException(e);
   }
 }
Пример #16
0
 public CookieInfo getCookie(HttpServletRequest request) {
   String value = new HttpCookie(LID_COOKIE_NAME).readValue(request);
   try {
     return (value == null) ? null : cookieCache.get(value);
   } catch (Exception e) {
     LOG.warn("Exception getting cookie from cache: " + e.getMessage());
     return null; // should be safe enough, user won't be able to access anything secure
   }
 }
 @Override
 public LocationGuesser getGuesser(String floorplanId) {
   try {
     final Floorplan fp = floorplans_.get(floorplanId);
     return new LocationGuesserImpl(strategies_, fp, fp.getRootType());
   } catch (Exception e) {
     throw new RuntimeException(e);
   }
 }
Пример #18
0
 @Override
 public SoyTofu.Renderer get(TemplateKey key) {
   SoyTofu.Renderer renderer = null;
   try {
     renderer = loadingCache.get(key);
   } catch (ExecutionException e) {
     e.printStackTrace();
   }
   return renderer;
 }
 /**
  * @param jwksUri
  * @return
  * @throws ExecutionException
  * @see com.google.common.cache.Cache#get(java.lang.Object)
  */
 public JwtSigningAndValidationService getValidator(String jwksUri) {
   try {
     return validators.get(jwksUri);
   } catch (UncheckedExecutionException ue) {
     logger.warn("Couldn't load JWK Set from " + jwksUri, ue);
     return null;
   } catch (ExecutionException e) {
     logger.warn("Couldn't load JWK Set from " + jwksUri, e);
     return null;
   }
 }
 public JwtEncryptionAndDecryptionService getEncrypter(String jwksUri) {
   try {
     return encrypters.get(jwksUri);
   } catch (UncheckedExecutionException ue) {
     logger.warn("Couldn't load JWK Set from " + jwksUri, ue);
     return null;
   } catch (ExecutionException e) {
     logger.warn("Couldn't load JWK Set from " + jwksUri, e);
     return null;
   }
 }
 @NotNull
 private static <T> T getCachedValueOrRethrowIO(
     @NotNull LoadingCache<String, ? extends T> cache, @NotNull String key) throws IOException {
   try {
     return cache.get(key);
   } catch (ExecutionException e) {
     final Throwable cause = e.getCause();
     throw (cause instanceof IOException
         ? (IOException) cause
         : new IOException("Unexpected non-IO error", cause));
   }
 }
Пример #22
0
 @Override
 public ImmutableMap<K, V> getAll(final Iterable<? extends K> elementKeys)
     throws ExecutionException {
   final ImmutableMap.Builder<K, V> builder = ImmutableMap.builder();
   for (final K key : elementKeys) {
     final LoadingCache<K, V> cache = getCache(key);
     if (cache != null) {
       final V value = cache.get(key);
       builder.put(key, value);
     }
   }
   return builder.build();
 }
 @Override
 public ChangeKind getChangeKind(
     ProjectState project, Repository repo, ObjectId prior, ObjectId next) {
   try {
     return cache.get(new Key(project, repo, prior, next, useRecursiveMerge));
   } catch (ExecutionException e) {
     log.warn(
         "Cannot check trivial rebase of new patch set "
             + next.name()
             + " in "
             + project.getProject().getName(),
         e);
     return ChangeKind.REWORK;
   }
 }
Пример #24
0
  public static boolean hasChar(PhysicalFont physicalFont, char c) throws ExecutionException {

    boolean exists = cache.get(physicalFont).hasChar(c);

    if (log.isWarnEnabled() && !exists) {

      log.warn(
          "Glyph "
              + (int) c
              + " (0x"
              + Integer.toHexString(c)
              + ") not available in font "
              + physicalFont.name);
    }

    return exists;
  }
Пример #25
0
 /**
  * Returns the timeout value in milliseconds to use for the specifed API call.
  *
  * @param name the name of the API call (configuration key is "timeout." + name
  * @param defaultValue the default value to use if the name wasn't configured explicitely
  * @param timeUnit the TimeUnit of the default value
  * @return the timeout in milliseconds
  */
 public static long apiTimeout(final String name, Integer defaultValue, TimeUnit timeUnit) {
   try {
     final Long configuredMillis = timeoutValues.get(name);
     if (configuredMillis == Long.MIN_VALUE) {
       return defaultValue == null
           ? TimeUnit.MILLISECONDS.convert(DEFAULT_TIMEOUT, TimeUnit.SECONDS)
           : TimeUnit.MILLISECONDS.convert(defaultValue, timeUnit);
     }
     return configuredMillis;
   } catch (ExecutionException ignored) {
     // we will never reach this
     LOG.error(
         "Unable to read timeout, this should never happen! Returning default timeout of "
             + DEFAULT_TIMEOUT
             + " seconds.");
     return DEFAULT_TIMEOUT;
   }
 }
  @Override
  public GroupDescription.Basic get(final AccountGroup.UUID uuid) {
    if (!handles(uuid)) {
      return null;
    }

    String groupDn = uuid.get().substring(LDAP_UUID.length());
    CurrentUser user = userProvider.get();
    if (!(user instanceof IdentifiedUser) || !membershipsOf((IdentifiedUser) user).contains(uuid)) {
      try {
        if (!existsCache.get(groupDn)) {
          return null;
        }
      } catch (ExecutionException e) {
        log.warn(String.format("Cannot lookup group %s in LDAP", groupDn), e);
        return null;
      }
    }

    final String name = LDAP_NAME + cnFor(groupDn);
    return new GroupDescription.Basic() {
      @Override
      public AccountGroup.UUID getGroupUUID() {
        return uuid;
      }

      @Override
      public String getName() {
        return name;
      }

      @Override
      @Nullable
      public String getEmailAddress() {
        return null;
      }

      @Override
      @Nullable
      public String getUrl() {
        return null;
      }
    };
  }
 public static Element getElementById(String srsId) throws DocumentException, IOException {
   Element elem = null;
   try {
     elem = lookupDocument.get(srsId).getRootElement();
   } catch (ExecutionException e) {
     try {
       throw e.getCause();
     } catch (DocumentException e2) {
       throw e2;
     } catch (MalformedURLException e2) {
       throw e2;
     } catch (IOException e2) {
       throw e2;
     } catch (Throwable e2) {
       throw new RuntimeException("Unrecognised ExecutionException", e2);
     }
   }
   return elem;
 }
 public static Document getDocumentById(String srsId) throws DocumentException, IOException {
   Document doc = null;
   try {
     doc = lookupDocument.get(srsId);
   } catch (ExecutionException e) {
     try {
       throw e.getCause();
     } catch (DocumentException e2) {
       throw e2;
     } catch (MalformedURLException e2) {
       throw e2;
     } catch (IOException e2) {
       throw e2;
     } catch (Throwable e2) {
       throw new RuntimeException("Unrecognised ExecutionException", e2);
     }
   }
   return doc;
 }
 public static Set<String> getSecondaryAccessions(String enaId)
     throws DocumentException, IOException {
   Element elem = null;
   try {
     elem = lookupDocument.get(enaId).getRootElement();
   } catch (ExecutionException e) {
     try {
       throw e.getCause();
     } catch (DocumentException e2) {
       throw e2;
     } catch (MalformedURLException e2) {
       throw e2;
     } catch (IOException e2) {
       throw e2;
     } catch (Throwable e2) {
       throw new RuntimeException("Unrecognised ExecutionException", e2);
     }
   }
   return getSecondaryAccessions(elem);
 }
  @Override
  public void invalidateBasedOn(WatchEvent<?> event) throws InterruptedException {
    if (!WatchEvents.isPathChangeEvent(event)) {
      // Non-path change event, likely an overflow due to many change events: invalidate everything.
      LOG.debug("Parser invalidating entire cache on overflow.");

      invalidateAllCaches();
      return;
    }

    Path path = (Path) event.context();

    for (Cell cell : knownCells) {
      try {
        if (isPathCreateOrDeleteEvent(event)) {
          BuildFileTree buildFiles = buildFileTrees.get(cell);

          if (path.endsWith(cell.getBuildFileName())) {
            // If a build file has been added or removed, reconstruct the build file tree.
            buildFileTrees.invalidate(cell);
          }

          // Added or removed files can affect globs, so invalidate the package build file
          // "containing" {@code path} unless its filename matches a temp file pattern.
          if (!isTempFile(cell, path)) {
            invalidateContainingBuildFile(cell, buildFiles, path);
          }

          LOG.verbose("Invalidating dependents for path %s, cache state %s", path, this);
        }
      } catch (ExecutionException | UncheckedExecutionException e) {
        try {
          throw propagate(e);
        } catch (BuildFileParseException bfpe) {
          LOG.warn("Unable to parse already parsed build file.", bfpe);
        }
      }
    }

    invalidatePath(path);
  }