@@ -49,7 +49,7 @@ public class PoolingRackApplicationFactory extends RackApplicationFactoryDecorat
4949 // 10 seconds seems still too much for a default, has been 30 previously :
5050 private static final float ACQUIRE_DEFAULT = 10.0f ;
5151
52- protected final Queue <RackApplication > applicationPool = new LinkedList <RackApplication >();
52+ protected final Queue <RackApplication > applicationPool = new LinkedList <>();
5353 private Integer initialSize , maximumSize ;
5454
5555 private final AtomicInteger initedApplications = new AtomicInteger (0 );
@@ -111,7 +111,7 @@ public void setAcquireTimeout(Number acquireTimeout) {
111111
112112 @ Override
113113 protected void doInit () throws Exception {
114- super .doInit (); // delegate.init(rackContext);
114+ super .doInit ();
115115 final RackConfig config = getConfig ();
116116 // TODO until config.getRuntimeTimeoutSeconds returns an integer :
117117 Number timeout = config .getNumberProperty ("jruby.runtime.acquire.timeout" );
@@ -253,16 +253,15 @@ public void destroy() {
253253 synchronized (applicationPool ) {
254254 for (RackApplication app : applicationPool ) {
255255 getDelegate ().finishedWithApplication (app );
256- // DefaultRackAppFactory: app.destroy();
257256 }
258257 applicationPool .clear ();
259258 }
260- super .destroy (); // delegate.destroy();
259+ super .destroy ();
261260 }
262261
263262 /**
264263 * Fills the initial pool with initialized application instances.
265- *
264+ * <p>
266265 * Application objects are created in foreground threads to avoid
267266 * leakage when the web application is undeployed from the server.
268267 */
@@ -294,19 +293,15 @@ protected void launchInitialization(final Queue<RackApplication> apps) {
294293 if ( initThreads == null ) initThreads = 4 ; // quad-core baby
295294
296295 for (int i = 0 ; i < initThreads ; i ++) {
297- new Thread (new Runnable () {
298- @ Override
299- public void run () {
300- while (true ) {
301- final RackApplication app ;
302- synchronized (apps ) {
303- if ( apps .isEmpty () ) break ;
304- app = apps .remove ();
305- }
306- if ( ! initAndPutApplicationToPool (app ) ) break ;
296+ new Thread (() -> {
297+ while (true ) {
298+ final RackApplication app ;
299+ synchronized (apps ) {
300+ if ( apps .isEmpty () ) break ;
301+ app = apps .remove ();
307302 }
303+ if ( ! initAndPutApplicationToPool (app ) ) break ;
308304 }
309-
310305 }, "JRuby-Rack-App-Init-" + i ).start ();
311306 }
312307 }
@@ -395,14 +390,14 @@ private int getInitialPoolSizeWait() {
395390 if ( waitNum != null ) {
396391 int wait = waitNum .intValue ();
397392 if (maximumSize != null && wait > maximumSize ) {
398- wait = maximumSize . intValue () ;
393+ wait = maximumSize ;
399394 }
400395 return wait ;
401396 }
402397 // otherwise we assume it to be a boolean true/false flag :
403398 Boolean waitFlag = getConfig ().getBooleanProperty ("jruby.runtime.init.wait" );
404399 if ( waitFlag == null ) waitFlag = Boolean .TRUE ;
405- return waitFlag ? ( initialSize == null ? 1 : initialSize . intValue () ) : 0 ;
400+ return waitFlag ? ( initialSize == null ? 1 : initialSize ) : 0 ;
406401 // NOTE: this slightly changes the behavior in 1.1.8, in previous
407402 // versions the initialization only waited for 1 application instance
408403 // to be available in the pool - here by default we wait till initial
@@ -411,14 +406,14 @@ private int getInitialPoolSizeWait() {
411406
412407 @ Override
413408 public Collection <RackApplication > getManagedApplications () {
414- int initSize = initialSize != null ? initialSize . intValue () : -1 ;
409+ int initSize = initialSize != null ? initialSize : -1 ;
415410 synchronized (applicationPool ) {
416411 if ( applicationPool .isEmpty () ) {
417412 if ( initSize > 0 ) return null ; // ~ init error
418413 return Collections .emptySet ();
419414 }
420415 Collection <RackApplication > snapshot =
421- new ArrayList <RackApplication >(applicationPool );
416+ new ArrayList <>(applicationPool );
422417 return Collections .unmodifiableCollection (snapshot );
423418 }
424419 }
0 commit comments