示例#1
0
 private void reportLeak(Level level) {
   if (!logger.isErrorEnabled()) {
     for (; ; ) {
       ResourceLeakDetector<T>.DefaultResourceLeak ref =
           (DefaultResourceLeak) this.refQueue.poll();
       if (ref == null) {
         break;
       }
       ref.close();
     }
     return;
   }
   int samplingInterval = level == Level.PARANOID ? 1 : this.samplingInterval;
   if ((this.active * samplingInterval > this.maxActive)
       && (this.loggedTooManyActive.compareAndSet(false, true))) {
     logger.error(
         "LEAK: You are creating too many "
             + this.resourceType
             + " instances.  "
             + this.resourceType
             + " is a shared resource that must be reused across the JVM,"
             + "so that only a few instances are created.");
   }
   for (; ; ) {
     ResourceLeakDetector<T>.DefaultResourceLeak ref = (DefaultResourceLeak) this.refQueue.poll();
     if (ref == null) {
       break;
     }
     ref.clear();
     if (ref.close()) {
       String records = ref.toString();
       if (this.reportedLeaks.putIfAbsent(records, Boolean.TRUE) == null) {
         if (records.isEmpty()) {
           logger.error(
               "LEAK: {}.release() was not called before it's garbage-collected. Enable advanced leak reporting to find out where the leak occurred. To enable advanced leak reporting, specify the JVM option '-D{}={}' or call {}.setLevel()",
               new Object[] {
                 this.resourceType,
                 "io.netty.leakDetectionLevel",
                 Level.ADVANCED.name().toLowerCase(),
                 StringUtil.simpleClassName(this)
               });
         } else {
           logger.error(
               "LEAK: {}.release() was not called before it's garbage-collected.{}",
               this.resourceType,
               records);
         }
       }
     }
   }
 }
 private static void processGoAwayWriteResult(
     final ChannelHandlerContext ctx,
     final int lastStreamId,
     final long errorCode,
     final ByteBuf debugData,
     ChannelFuture future) {
   try {
     if (future.isSuccess()) {
       if (errorCode != NO_ERROR.code()) {
         if (logger.isDebugEnabled()) {
           logger.debug(
               format(
                   "Sent GOAWAY: lastStreamId '%d', errorCode '%d', "
                       + "debugData '%s'. Forcing shutdown of the connection.",
                   lastStreamId, errorCode, debugData.toString(UTF_8)),
               future.cause());
         }
         ctx.close();
       }
     } else {
       if (logger.isErrorEnabled()) {
         logger.error(
             format(
                 "Sending GOAWAY failed: lastStreamId '%d', errorCode '%d', "
                     + "debugData '%s'. Forcing shutdown of the connection.",
                 lastStreamId, errorCode, debugData.toString(UTF_8)),
             future.cause());
       }
       ctx.close();
     }
   } finally {
     // We're done with the debug data now.
     debugData.release();
   }
 }
示例#3
0
    private synchronized void registerActorClasses() {
      if (actorClasses.isEmpty()) {
        try {
          final ClassLoader classLoader =
              userClassLoader != null ? userClassLoader : this.getClass().getClassLoader();
          ClassLoaderUtil.accept(
              (URLClassLoader) classLoader,
              new ClassLoaderUtil.Visitor() {
                @Override
                public final void visit(String resource, URL url, ClassLoader cl) {
                  if (packagePrefixes != null) {
                    boolean found = false;
                    for (final String packagePrefix : packagePrefixes) {
                      if (packagePrefix != null
                          && resource.startsWith(packagePrefix.replace('.', '/'))) {
                        found = true;
                        break;
                      }
                    }
                    if (!found) return;
                  }
                  if (!ClassLoaderUtil.isClassFile(resource)) return;
                  final String className = ClassLoaderUtil.resourceToClass(resource);
                  try (final InputStream is = cl.getResourceAsStream(resource)) {
                    if (AnnotationUtil.hasClassAnnotation(WebActor.class, is))
                      registerWebActor(cl.loadClass(className));
                  } catch (final IOException | ClassNotFoundException e) {
                    log.error(
                        "Exception while scanning class " + className + " for WebActor annotation",
                        e);
                    throw new RuntimeException(e);
                  }
                }

                private void registerWebActor(Class<?> c) {
                  actorClasses.add(c);
                }
              });
        } catch (final IOException e) {
          log.error("IOException while scanning classes for WebActor annotation", e);
        }
      }
    }
 @Override
 public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
   ctx.close();
   logger.error("catch the exception:", cause);
 }
示例#5
0
 @Override
 public final void close(Throwable t) {
   log.error("Exception while closing HTTP adapter", t);
   if (actor != null) actor.die(t);
 }
示例#6
0
 public void error(Object arg0, Throwable arg1) {
   if (arg1 == null) return;
   if (arg0 != null) _log.error(arg0.toString(), arg1);
   else _log.error("null", arg1);
 }
示例#7
0
 public void error(Object arg0) {
   if (arg0 != null) _log.error(arg0.toString());
   else _log.error("null");
 }