Search in sources :

Example 16 with Logger

use of com.intellij.openapi.diagnostic.Logger in project intellij-community by JetBrains.

the class PortUnificationServerHandler method decode.

protected void decode(@NotNull ChannelHandlerContext context, @NotNull ByteBuf buffer) throws Exception {
    ChannelPipeline pipeline = context.pipeline();
    if (detectSsl && SslHandler.isEncrypted(buffer)) {
        SSLEngine engine = SSL_SERVER_CONTEXT.getValue().createSSLEngine();
        engine.setUseClientMode(false);
        pipeline.addLast(new SslHandler(engine), new ChunkedWriteHandler(), new PortUnificationServerHandler(delegatingHttpRequestHandler, false, detectGzip));
    } else {
        int magic1 = buffer.getUnsignedByte(buffer.readerIndex());
        int magic2 = buffer.getUnsignedByte(buffer.readerIndex() + 1);
        if (detectGzip && magic1 == 31 && magic2 == 139) {
            pipeline.addLast(ZlibCodecFactory.newZlibEncoder(ZlibWrapper.GZIP), ZlibCodecFactory.newZlibDecoder(ZlibWrapper.GZIP), new PortUnificationServerHandler(delegatingHttpRequestHandler, detectSsl, false));
        } else if (isHttp(magic1, magic2)) {
            NettyUtil.addHttpServerCodec(pipeline);
            pipeline.addLast("delegatingHttpHandler", delegatingHttpRequestHandler);
            final Logger logger = Logger.getInstance(BuiltInServer.class);
            if (logger.isDebugEnabled()) {
                pipeline.addLast(new ChannelOutboundHandlerAdapter() {

                    @Override
                    public void write(ChannelHandlerContext context, Object message, ChannelPromise promise) throws Exception {
                        if (message instanceof HttpResponse) {
                            HttpResponse response = (HttpResponse) message;
                            logger.debug("OUT HTTP: " + response.toString());
                        }
                        super.write(context, message, promise);
                    }
                });
            }
        } else if (magic1 == 'C' && magic2 == 'H') {
            buffer.skipBytes(2);
            pipeline.addLast(new CustomHandlerDelegator());
        } else {
            Logger.getInstance(BuiltInServer.class).warn("unknown request, first two bytes " + magic1 + " " + magic2);
            context.close();
        }
    }
    // must be after new channels handlers addition (netty bug?)
    pipeline.remove(this);
    // Buffer will be automatically released after messageReceived, but we pass it to next handler, and next handler will also release, so, we must retain.
    // We can introduce Decoder.isAutoRelease, but in this case, if error will be thrown while we are executing, buffer will not be released.
    // So, it is robust solution just always release (Decoder does) and just retain (we - client) if autorelease behavior is not suitable.
    buffer.retain();
    // we must fire channel read - new added handler must read buffer
    context.fireChannelRead(buffer);
}
Also used : SSLEngine(javax.net.ssl.SSLEngine) HttpResponse(io.netty.handler.codec.http.HttpResponse) Logger(com.intellij.openapi.diagnostic.Logger) SslHandler(io.netty.handler.ssl.SslHandler) ChunkedWriteHandler(io.netty.handler.stream.ChunkedWriteHandler)

Example 17 with Logger

use of com.intellij.openapi.diagnostic.Logger in project intellij-community by JetBrains.

the class UnsupportedFeaturesUtil method fillMaps.

private static void fillMaps() throws IOException {
    Logger log = Logger.getInstance(UnsupportedFeaturesUtil.class.getName());
    FileReader reader = new FileReader(PythonHelpersLocator.getHelperPath("/tools/versions.xml"));
    try {
        XMLReader xr = XMLReaderFactory.createXMLReader();
        VersionsParser parser = new VersionsParser();
        xr.setContentHandler(parser);
        xr.parse(new InputSource(reader));
    } catch (SAXException e) {
        log.error("Improperly formed \"versions.xml\". " + e.getMessage());
    } finally {
        reader.close();
    }
}
Also used : InputSource(org.xml.sax.InputSource) FileReader(java.io.FileReader) Logger(com.intellij.openapi.diagnostic.Logger) XMLReader(org.xml.sax.XMLReader) SAXException(org.xml.sax.SAXException)

Aggregations

Logger (com.intellij.openapi.diagnostic.Logger)17 Nullable (org.jetbrains.annotations.Nullable)5 File (java.io.File)3 StringUtil (com.intellij.openapi.util.text.StringUtil)2 IOException (java.io.IOException)2 java.util (java.util)2 NotNull (org.jetbrains.annotations.NotNull)2 SdkConstants (com.android.SdkConstants)1 VisibleForTesting (com.android.annotations.VisibleForTesting)1 CollectingOutputReceiver (com.android.ddmlib.CollectingOutputReceiver)1 LayoutLog (com.android.ide.common.rendering.api.LayoutLog)1 TAG_RESOURCES_PREFIX (com.android.ide.common.rendering.api.LayoutLog.TAG_RESOURCES_PREFIX)1 TAG_RESOURCES_RESOLVE_THEME_ATTR (com.android.ide.common.rendering.api.LayoutLog.TAG_RESOURCES_RESOLVE_THEME_ATTR)1 ResourceResolver (com.android.ide.common.resources.ResourceResolver)1 RenderSessionImpl (com.android.layoutlib.bridge.impl.RenderSessionImpl)1 Density (com.android.resources.Density)1 IAndroidTarget (com.android.sdklib.IAndroidTarget)1 AndroidModuleInfo (com.android.tools.idea.model.AndroidModuleInfo)1 TAG_STILL_BUILDING (com.android.tools.idea.rendering.RenderLogger.TAG_STILL_BUILDING)1 RenderErrorModel (com.android.tools.idea.rendering.errors.ui.RenderErrorModel)1