spark中的bug记录

 kafkaStream.foreachRDD(new VoidFunction<JavaRDD<ConsumerRecord<Object, Object>>>() {

            public void call(JavaRDD<ConsumerRecord<Object, Object>> t){
                 
               
                    t.foreach(new VoidFunction<ConsumerRecord<Object, Object>>() {

                        public void call(ConsumerRecord<Object, Object> t) {

                            System.out.println(t.toString());
                            int i = 1 / 0;
                        }
                    }); 
                
            }
        });

    t.foreach(){} 中的 int i = 1/0;的异常不会到最外层,会在foreach中自行消化  在foreachRDD中的异常会被抛出到最外层

猜你喜欢

转载自blog.csdn.net/aa1358075776/article/details/82453665