View | Details | Raw Unified | Return to bug 62757
Collapse All | Expand All

(-)java/org/apache/jasper/compiler/JspRuntimeContext.java (-2 / +1 lines)
Lines 378-385 Link Here
378
        for (int i = 0; i < wrappers.length; i++ ) {
378
        for (int i = 0; i < wrappers.length; i++ ) {
379
            JspServletWrapper jsw = (JspServletWrapper)wrappers[i];
379
            JspServletWrapper jsw = (JspServletWrapper)wrappers[i];
380
            JspCompilationContext ctxt = jsw.getJspEngineContext();
380
            JspCompilationContext ctxt = jsw.getJspEngineContext();
381
            // JspServletWrapper also synchronizes on this when
381
            // Sync on JspServletWrapper when calling ctxt.compile()
382
            // it detects it has to do a reload
383
            synchronized(jsw) {
382
            synchronized(jsw) {
384
                try {
383
                try {
385
                    ctxt.compile();
384
                    ctxt.compile();
(-)java/org/apache/jasper/compiler/TagFileProcessor.java (-2 / +1 lines)
Lines 543-554 Link Here
543
                        wrapper = new JspServletWrapper(ctxt.getServletContext(), ctxt
543
                        wrapper = new JspServletWrapper(ctxt.getServletContext(), ctxt
544
                                .getOptions(), tagFilePath, tagInfo, ctxt
544
                                .getOptions(), tagFilePath, tagInfo, ctxt
545
                                .getRuntimeContext(), tagJar);
545
                                .getRuntimeContext(), tagJar);
546
                        rctxt.addWrapper(wrapperUri, wrapper);
547
548
                        // Use same classloader and classpath for compiling tag files
546
                        // Use same classloader and classpath for compiling tag files
549
                        wrapper.getJspEngineContext().setClassLoader(
547
                        wrapper.getJspEngineContext().setClassLoader(
550
                                ctxt.getClassLoader());
548
                                ctxt.getClassLoader());
551
                        wrapper.getJspEngineContext().setClassPath(ctxt.getClassPath());
549
                        wrapper.getJspEngineContext().setClassPath(ctxt.getClassPath());
550
                        rctxt.addWrapper(wrapperUri, wrapper);
552
                    } else {
551
                    } else {
553
                        // Make sure that JspCompilationContext gets the latest TagInfo
552
                        // Make sure that JspCompilationContext gets the latest TagInfo
554
                        // for the tag file. TagInfo instance was created the last
553
                        // for the tag file. TagInfo instance was created the last
(-)java/org/apache/jasper/servlet/JspServletWrapper.java (-18 / +27 lines)
Lines 89-95 Link Here
89
    private long available = 0L;
89
    private long available = 0L;
90
    private final ServletConfig config;
90
    private final ServletConfig config;
91
    private final Options options;
91
    private final Options options;
92
    private volatile boolean firstTime = true;
93
    /** Whether the servlet needs reloading on next access */
92
    /** Whether the servlet needs reloading on next access */
94
    private volatile boolean reload = true;
93
    private volatile boolean reload = true;
95
    private final boolean isTagFile;
94
    private final boolean isTagFile;
Lines 158-164 Link Here
158
    }
157
    }
159
158
160
    private boolean getReloadInternal() {
159
    private boolean getReloadInternal() {
161
        return firstTime || reload && !ctxt.getRuntimeContext().isCompileCheckInProgress();
160
        return reload && !ctxt.getRuntimeContext().isCompileCheckInProgress();
162
    }
161
    }
163
162
164
    public Servlet getServlet() throws ServletException {
163
    public Servlet getServlet() throws ServletException {
Lines 171-181 Link Here
171
         * possible (see BZ 62603) for a race condition to cause failures
170
         * possible (see BZ 62603) for a race condition to cause failures
172
         * if a Servlet or tag is reloaded while a compile check is running
171
         * if a Servlet or tag is reloaded while a compile check is running
173
         */
172
         */
174
        if (getReloadInternal()) {
173
        if (getReloadInternal() || theServlet == null) {
175
            synchronized (this) {
174
            synchronized (this) {
176
                // Synchronizing on jsw enables simultaneous loading
175
                // Synchronizing on jsw enables simultaneous loading
177
                // of different pages, but not the same page.
176
                // of different pages, but not the same page.
178
                if (getReloadInternal()) {
177
                if (getReloadInternal() || theServlet == null) {
179
                    // This is to maintain the original protocol.
178
                    // This is to maintain the original protocol.
180
                    destroy();
179
                    destroy();
181
180
Lines 193-199 Link Here
193
192
194
                    servlet.init(config);
193
                    servlet.init(config);
195
194
196
                    if (!firstTime) {
195
                    if (theServlet != null) {
197
                        ctxt.getRuntimeContext().incrementJspReloadCount();
196
                        ctxt.getRuntimeContext().incrementJspReloadCount();
198
                    }
197
                    }
199
198
Lines 257-266 Link Here
257
            if (ctxt.isRemoved()) {
256
            if (ctxt.isRemoved()) {
258
                throw new FileNotFoundException(jspUri);
257
                throw new FileNotFoundException(jspUri);
259
            }
258
            }
260
            if (options.getDevelopment() || firstTime ) {
259
            if (options.getDevelopment() || tagHandlerClass == null) {
261
                synchronized (this) {
260
                synchronized (this) {
262
                    firstTime = false;
261
                    if (options.getDevelopment() || tagHandlerClass == null) {
263
                    ctxt.compile();
262
                        ctxt.compile();
263
                    }
264
                }
264
                }
265
            } else {
265
            } else {
266
                if (compileException != null) {
266
                if (compileException != null) {
Lines 268-276 Link Here
268
                }
268
                }
269
            }
269
            }
270
270
271
            if (getReloadInternal()) {
271
            if (getReloadInternal() || tagHandlerClass == null) {
272
                tagHandlerClass = ctxt.load();
272
                synchronized (this) {
273
                reload = false;
273
                    if (getReloadInternal() || tagHandlerClass == null) {
274
                        tagHandlerClass = ctxt.load();
275
                        // Volatile 'reload' forces in order write of 'tagHandlerClass'
276
                        reload = false;
277
                    }
278
                }
274
            }
279
            }
275
        } catch (FileNotFoundException ex) {
280
        } catch (FileNotFoundException ex) {
276
            throw new JasperException(ex);
281
            throw new JasperException(ex);
Lines 306-313 Link Here
306
            Object target;
311
            Object target;
307
            if (isTagFile) {
312
            if (isTagFile) {
308
                if (reload) {
313
                if (reload) {
309
                    tagHandlerClass = ctxt.load();
314
                    synchronized (this) {
310
                    reload = false;
315
                        if (reload) {
316
                            tagHandlerClass = ctxt.load();
317
                            reload = false;
318
                        }
319
                    }
311
                }
320
                }
312
                target = tagHandlerClass.newInstance();
321
                target = tagHandlerClass.newInstance();
313
            } else {
322
            } else {
Lines 375-386 Link Here
375
            /*
384
            /*
376
             * (1) Compile
385
             * (1) Compile
377
             */
386
             */
378
            if (options.getDevelopment() || firstTime ) {
387
            if (options.getDevelopment() || theServlet == null) {
379
                synchronized (this) {
388
                synchronized (this) {
380
                    firstTime = false;
389
                    if (options.getDevelopment() || theServlet == null) {
381
390
                        // The following sets reload to true, if necessary
382
                    // The following sets reload to true, if necessary
391
                        ctxt.compile();
383
                    ctxt.compile();
392
                    }
384
                }
393
                }
385
            } else {
394
            } else {
386
                if (compileException != null) {
395
                if (compileException != null) {

Return to bug 62757