[
https://issues.apache.org/jira/browse/DRILL-4946?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15634266#comment-15634266
]
ASF GitHub Bot commented on DRILL-4946:
---------------------------------------
Github user paul-rogers commented on a diff in the pull request:
https://github.com/apache/drill/pull/619#discussion_r86435395
--- Diff:
exec/java-exec/src/main/java/org/apache/drill/exec/util/StdErrCapturer.java ---
@@ -0,0 +1,83 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.drill.exec.util;
+
+
+import java.io.ByteArrayOutputStream;
+import java.io.OutputStream;
+import java.io.PrintStream;
+import java.nio.charset.StandardCharsets;
+
+/**
+ * The safe way to use this class is to redirect System.err to
nullOutputStream.
+ * If callers want to get the redirected output -ito print or log
elsewhere - as used in unit tests and they
+ * need the output to be neat, then there should be advanced ways to
preserve the output to avoid concurrent
+ * inputs messing up. But this class is not designed for that.
+ */
+public class StdErrCapturer {
+ static private PrintStream savedStdErr;
+ static private OutputStream buffer;
+ static private PrintStream capturingStream;
+ static Boolean redirected = false;
+
+ public static void redirect() {
--- End diff --
Do in constructor (so it can be reversed in close.)
> org.objectweb.asm.tree.analysis.AnalyzerException printed to console in
> embedded mode
> -------------------------------------------------------------------------------------
>
> Key: DRILL-4946
> URL: https://issues.apache.org/jira/browse/DRILL-4946
> Project: Apache Drill
> Issue Type: Bug
> Reporter: Chunhui Shi
> Assignee: Boaz Ben-Zvi
> Priority: Critical
>
> Testing by querying a json file got AnalyzerException printed.
> The problem was due to scalar_replacement mode is default to be 'try', and
> org.objectweb.asm.util.CheckMethodAdapter is printing stack trace to stderr.
> [shi@cshi-centos1 private-drill]$ cat /tmp/conv.json
> {"row": "0", "key": "\\x4a\\x31\\x39\\x38", "key2": "4a313938", "kp1":
> "4a31", "kp2": "38"}
> {"row": "1", "key": null, "key2": null, "kp1": null, "kp2": null}
> {"row": "2", "key": "\\x4e\\x4f\\x39\\x51", "key2": "4e4f3951", "kp1":
> "4e4f", "kp2": "51"}
> {"row": "3", "key": "\\x6e\\x6f\\x39\\x31", "key2": "6e6f3931", "kp1":
> "6e6f", "kp2": "31"}
> 0: jdbc:drill:zk=local> SELECT convert_from(binary_string(key), 'INT_BE') as
> intkey from dfs.`/tmp/conv.json`;
> org.objectweb.asm.tree.analysis.AnalyzerException: Error at instruction 158:
> Expected an object reference, but found .
> at org.objectweb.asm.tree.analysis.Analyzer.analyze(Analyzer.java:294)
> at
> org.objectweb.asm.util.CheckMethodAdapter$1.visitEnd(CheckMethodAdapter.java:450)
> at org.objectweb.asm.MethodVisitor.visitEnd(MethodVisitor.java:877)
> at
> org.objectweb.asm.util.CheckMethodAdapter.visitEnd(CheckMethodAdapter.java:1028)
> at org.objectweb.asm.MethodVisitor.visitEnd(MethodVisitor.java:877)
> at
> org.apache.drill.exec.compile.CheckMethodVisitorFsm.visitEnd(CheckMethodVisitorFsm.java:114)
> at org.objectweb.asm.MethodVisitor.visitEnd(MethodVisitor.java:877)
> at
> org.apache.drill.exec.compile.CheckMethodVisitorFsm.visitEnd(CheckMethodVisitorFsm.java:114)
> at org.objectweb.asm.MethodVisitor.visitEnd(MethodVisitor.java:877)
> at org.objectweb.asm.MethodVisitor.visitEnd(MethodVisitor.java:877)
> at
> org.apache.drill.exec.compile.bytecode.InstructionModifier.visitEnd(InstructionModifier.java:508)
> at org.objectweb.asm.tree.MethodNode.accept(MethodNode.java:837)
> at
> org.apache.drill.exec.compile.bytecode.ScalarReplacementNode.visitEnd(ScalarReplacementNode.java:87)
> at org.objectweb.asm.MethodVisitor.visitEnd(MethodVisitor.java:877)
> at
> org.apache.drill.exec.compile.bytecode.AloadPopRemover.visitEnd(AloadPopRemover.java:136)
> at org.objectweb.asm.tree.MethodNode.accept(MethodNode.java:837)
> at org.objectweb.asm.tree.MethodNode.accept(MethodNode.java:726)
> at org.objectweb.asm.tree.ClassNode.accept(ClassNode.java:412)
> at
> org.apache.drill.exec.compile.MergeAdapter.getMergedClass(MergeAdapter.java:223)
> at
> org.apache.drill.exec.compile.ClassTransformer.getImplementationClass(ClassTransformer.java:263)
> at
> org.apache.drill.exec.compile.CodeCompiler$Loader.load(CodeCompiler.java:78)
> at
> org.apache.drill.exec.compile.CodeCompiler$Loader.load(CodeCompiler.java:74)
> at
> com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3527)
> at
> com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2319)
> at
> com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2282)
> at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2197)
> at com.google.common.cache.LocalCache.get(LocalCache.java:3937)
> at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3941)
> at
> com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4824)
> at
> org.apache.drill.exec.compile.CodeCompiler.getImplementationClass(CodeCompiler.java:63)
> at
> org.apache.drill.exec.compile.CodeCompiler.getImplementationClass(CodeCompiler.java:56)
> at
> org.apache.drill.exec.ops.FragmentContext.getImplementationClass(FragmentContext.java:310)
> at
> org.apache.drill.exec.physical.impl.project.ProjectRecordBatch.setupNewSchema(ProjectRecordBatch.java:484)
> at
> org.apache.drill.exec.record.AbstractSingleRecordBatch.innerNext(AbstractSingleRecordBatch.java:78)
> at
> org.apache.drill.exec.physical.impl.project.ProjectRecordBatch.innerNext(ProjectRecordBatch.java:135)
> at
> org.apache.drill.exec.record.AbstractRecordBatch.next(AbstractRecordBatch.java:162)
> at
> org.apache.drill.exec.physical.impl.BaseRootExec.next(BaseRootExec.java:104)
> at
> org.apache.drill.exec.physical.impl.ScreenCreator$ScreenRoot.innerNext(ScreenCreator.java:81)
> at
> org.apache.drill.exec.physical.impl.BaseRootExec.next(BaseRootExec.java:94)
> at
> org.apache.drill.exec.work.fragment.FragmentExecutor$1.run(FragmentExecutor.java:232)
> at
> org.apache.drill.exec.work.fragment.FragmentExecutor$1.run(FragmentExecutor.java:226)
> at java.security.AccessController.doPrivileged(Native Method)
> at javax.security.auth.Subject.doAs(Subject.java:415)
> at
> org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1657)
> at
> org.apache.drill.exec.work.fragment.FragmentExecutor.run(FragmentExecutor.java:226)
> at
> org.apache.drill.common.SelfCleaningRunnable.run(SelfCleaningRunnable.java:38)
> at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
> at java.lang.Thread.run(Thread.java:745)
> Caused by: org.objectweb.asm.tree.analysis.AnalyzerException: Expected an
> object reference, but found .
> at
> org.objectweb.asm.tree.analysis.BasicVerifier.copyOperation(BasicVerifier.java:80)
> at
> org.objectweb.asm.tree.analysis.BasicVerifier.copyOperation(BasicVerifier.java:47)
> at org.objectweb.asm.tree.analysis.Frame.execute(Frame.java:276)
> at org.objectweb.asm.tree.analysis.Analyzer.analyze(Analyzer.java:199)
> ... 48 more
> +-------------+
> | intkey |
> +-------------+
> | 1244739896 |
> | null |
> | 1313814865 |
> | 1852782897 |
> +-------------+
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)