Bug:ForkJoinTask的异常获取错误

这是个低级错误,本意是在获取异常对象时,假如当前线程不是抛出异常的线程则尽可能重新new一个,但是判断语句混入了.....:

        if (false && e.thrower != Thread.currentThread().getId()) {
            Class ec = ex.getClass();
            try {
                Constructor noArgCtor = null;
                Constructor[] cs = ec.getConstructors();// public ctors only
                for (int i = 0; i < cs.length; ++i) {
                    Constructor c = cs[i];
                    Class[] ps = c.getParameterTypes();
                    if (ps.length == 0)
                        noArgCtor = c;
                    else if (ps.length == 1 && ps[0] == Throwable.class)
                        return (Throwable)(c.newInstance(ex));
                }
                if (noArgCtor != null) {
                    Throwable wx = (Throwable)(noArgCtor.newInstance());
                    wx.initCause(ex);
                    return wx;
                }
            } catch (Exception ignore) {
            }
        }

....

你可能感兴趣的:(JAVA,多线程,并发数据结构,Java)