コード例 #1
0
 public final synchronized T getInfo(URI uri, RenderingContext context) {
   T result = cache.get(uri);
   if (result == null) {
     try {
       result = requestInfo(uri, context);
     } catch (Exception e) {
       loader
           .logger()
           .info(
               "Error while getting capabilities for "
                   + uri
                   + ". The print module will assume it's a standard WMS.");
       String stackTrace = "";
       for (StackTraceElement el : e.getStackTrace()) {
         stackTrace += el.toString() + "\n";
       }
       loader.logger().info(stackTrace);
       result = loader.createNewErrorResult();
     }
     if (loader.logger().isDebugEnabled()) {
       loader.logger().debug("GetCapabilities " + uri + ": " + result);
     }
     cache.put(uri, result);
   }
   return result;
 }
コード例 #2
0
  protected static boolean wasCalledDuringClassLoading() {
    if (LOCK.isHeldByCurrentThread()) return true;
    LOCK.lock();

    try {
      StackTrace st = new StackTrace(new Throwable());
      int n = st.getDepth();

      for (int i = 3; i < n; i++) {
        StackTraceElement ste = st.getElement(i);

        if ("ClassLoader.java".equals(ste.getFileName())
            && "loadClass".equals(ste.getMethodName())) {
          return true;
        }
      }

      return false;
    } finally {
      LOCK.unlock();
    }
  }
コード例 #3
0
  // [JACKSON-888]
  public void testStackTraceElement() throws Exception {
    StackTraceElement elem = null;
    try {
      throw new IllegalStateException();
    } catch (Exception e) {
      elem = e.getStackTrace()[0];
    }
    String json = MAPPER.writeValueAsString(elem);
    StackTraceElement back = MAPPER.readValue(json, StackTraceElement.class);

    assertEquals("testStackTraceElement", back.getMethodName());
    assertEquals(elem.getLineNumber(), back.getLineNumber());
    assertEquals(elem.getClassName(), back.getClassName());
    assertEquals(elem.isNativeMethod(), back.isNativeMethod());
    assertTrue(back.getClassName().endsWith("TestJdkTypes"));
    assertFalse(back.isNativeMethod());
  }