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

(-)java/org/apache/jasper/compiler/TagFileProcessor.java (-2 / +1 lines)
Lines 542-553 Link Here
542
                        wrapper = new JspServletWrapper(ctxt.getServletContext(), ctxt
542
                        wrapper = new JspServletWrapper(ctxt.getServletContext(), ctxt
543
                                .getOptions(), tagFilePath, tagInfo, ctxt
543
                                .getOptions(), tagFilePath, tagInfo, ctxt
544
                                .getRuntimeContext(), tagJar);
544
                                .getRuntimeContext(), tagJar);
545
                        rctxt.addWrapper(wrapperUri, wrapper);
546
547
                        // Use same classloader and classpath for compiling tag files
545
                        // Use same classloader and classpath for compiling tag files
548
                        wrapper.getJspEngineContext().setClassLoader(
546
                        wrapper.getJspEngineContext().setClassLoader(
549
                                ctxt.getClassLoader());
547
                                ctxt.getClassLoader());
550
                        wrapper.getJspEngineContext().setClassPath(ctxt.getClassPath());
548
                        wrapper.getJspEngineContext().setClassPath(ctxt.getClassPath());
549
                        rctxt.addWrapper(wrapperUri, wrapper);
551
                    } else {
550
                    } else {
552
                        // Make sure that JspCompilationContext gets the latest TagInfo
551
                        // Make sure that JspCompilationContext gets the latest TagInfo
553
                        // for the tag file. TagInfo instance was created the last
552
                        // for the tag file. TagInfo instance was created the last
(-)java/org/apache/jasper/servlet/JspServletWrapper.java (-17 / +36 lines)
Lines 88-94 Link Here
88
    private long available = 0L;
88
    private long available = 0L;
89
    private final ServletConfig config;
89
    private final ServletConfig config;
90
    private final Options options;
90
    private final Options options;
91
    private boolean firstTime = true;
91
    private volatile boolean firstTime = true;
92
    /** Whether the servlet needs reloading on next access */
92
    /** Whether the servlet needs reloading on next access */
93
    private volatile boolean reload = true;
93
    private volatile boolean reload = true;
94
    private final boolean isTagFile;
94
    private final boolean isTagFile;
Lines 156-163 Link Here
156
        return reload;
156
        return reload;
157
    }
157
    }
158
158
159
    public boolean getFirstTime() {
160
        return firstTime;
161
    }
162
159
    private boolean getReloadInternal() {
163
    private boolean getReloadInternal() {
160
        return firstTime || reload && !ctxt.getRuntimeContext().isCompileCheckInProgress();
164
        return firstTime || (reload && !ctxt.getRuntimeContext().isCompileCheckInProgress());
165
    }
166
167
    private boolean mustCompile() {
168
        return options.getDevelopment() || firstTime;
161
    }
169
    }
162
170
163
    public Servlet getServlet() throws ServletException {
171
    public Servlet getServlet() throws ServletException {
Lines 170-180 Link Here
170
         * possible (see BZ 62603) for a race condition to cause failures
178
         * possible (see BZ 62603) for a race condition to cause failures
171
         * if a Servlet or tag is reloaded while a compile check is running
179
         * if a Servlet or tag is reloaded while a compile check is running
172
         */
180
         */
173
        if (getReloadInternal()) {
181
        if (getReloadInternal() || theServlet == null) {
174
            synchronized (this) {
182
            synchronized (this) {
175
                // Synchronizing on jsw enables simultaneous loading
183
                // Synchronizing on jsw enables simultaneous loading
176
                // of different pages, but not the same page.
184
                // of different pages, but not the same page.
177
                if (getReloadInternal()) {
185
                if (getReloadInternal() || theServlet == null) {
178
                    // This is to maintain the original protocol.
186
                    // This is to maintain the original protocol.
179
                    destroy();
187
                    destroy();
180
188
Lines 256-265 Link Here
256
            if (ctxt.isRemoved()) {
264
            if (ctxt.isRemoved()) {
257
                throw new FileNotFoundException(jspUri);
265
                throw new FileNotFoundException(jspUri);
258
            }
266
            }
259
            if (options.getDevelopment() || firstTime ) {
267
            if (mustCompile()) {
260
                synchronized (this) {
268
                synchronized (this) {
261
                    firstTime = false;
269
                    if (mustCompile()) {
262
                    ctxt.compile();
270
                        firstTime = false;
271
                        ctxt.compile();
272
                    }
263
                }
273
                }
264
            } else {
274
            } else {
265
                if (compileException != null) {
275
                if (compileException != null) {
Lines 267-275 Link Here
267
                }
277
                }
268
            }
278
            }
269
279
270
            if (getReloadInternal()) {
280
            if (reload) {
271
                tagHandlerClass = ctxt.load();
281
                synchronized (this) {
272
                reload = false;
282
                    if (reload) {
283
                        tagHandlerClass = ctxt.load();
284
                        reload = false;
285
                    }
286
                }
273
            }
287
            }
274
        } catch (FileNotFoundException ex) {
288
        } catch (FileNotFoundException ex) {
275
            throw new JasperException(ex);
289
            throw new JasperException(ex);
Lines 305-312 Link Here
305
            Object target;
319
            Object target;
306
            if (isTagFile) {
320
            if (isTagFile) {
307
                if (reload) {
321
                if (reload) {
308
                    tagHandlerClass = ctxt.load();
322
                    synchronized (this) {
309
                    reload = false;
323
                        if (reload) {
324
                            tagHandlerClass = ctxt.load();
325
                            reload = false;
326
                        }
327
                    }
310
                }
328
                }
311
                target = tagHandlerClass.getConstructor().newInstance();
329
                target = tagHandlerClass.getConstructor().newInstance();
312
            } else {
330
            } else {
Lines 374-385 Link Here
374
            /*
392
            /*
375
             * (1) Compile
393
             * (1) Compile
376
             */
394
             */
377
            if (options.getDevelopment() || firstTime ) {
395
            if (mustCompile()) {
378
                synchronized (this) {
396
                synchronized (this) {
379
                    firstTime = false;
397
                    if (mustCompile()) {
380
398
                        firstTime = false;
381
                    // The following sets reload to true, if necessary
399
                        // The following sets reload to true, if necessary
382
                    ctxt.compile();
400
                        ctxt.compile();
401
                    }
383
                }
402
                }
384
            } else {
403
            } else {
385
                if (compileException != null) {
404
                if (compileException != null) {
(-)java/org/apache/jasper/compiler/JspRuntimeContext.java (-4 / +6 lines)
Lines 374-384 Link Here
374
            // it detects it has to do a reload
374
            // it detects it has to do a reload
375
            synchronized(jsw) {
375
            synchronized(jsw) {
376
                try {
376
                try {
377
                    ctxt.compile();
377
                    if (!jsw.getFirstTime()) {
378
                    if (jsw.getReload()) {
378
                        ctxt.compile();
379
                        wrappersToReload.add(jsw);
379
                        if (jsw.getReload()) {
380
                            wrappersToReload.add(jsw);
381
                        }
380
                    }
382
                    }
381
                } catch (FileNotFoundException ex) {
383
               } catch (FileNotFoundException ex) {
382
                    ctxt.incrementRemoved();
384
                    ctxt.incrementRemoved();
383
                } catch (Throwable t) {
385
                } catch (Throwable t) {
384
                    ExceptionUtils.handleThrowable(t);
386
                    ExceptionUtils.handleThrowable(t);

Return to bug 62757