1376 boolean checkedWithFactory = false; 1377 1378 if (isOverrideable(protocol) && jdk.internal.misc.VM.isBooted()) { 1379 // Use the factory (if any). Volatile read makes 1380 // URLStreamHandlerFactory appear fully initialized to current thread. 1381 fac = factory; 1382 if (fac != null) { 1383 handler = fac.createURLStreamHandler(protocol); 1384 checkedWithFactory = true; 1385 } 1386 1387 if (handler == null && !protocol.equalsIgnoreCase("jar")) { 1388 handler = lookupViaProviders(protocol); 1389 } 1390 1391 if (handler == null) { 1392 handler = lookupViaProperty(protocol); 1393 } 1394 } 1395 1396 synchronized (streamHandlerLock) { 1397 if (handler == null) { 1398 // Try the built-in protocol handler 1399 handler = defaultFactory.createURLStreamHandler(protocol); 1400 } else { 1401 URLStreamHandler handler2 = null; 1402 1403 // Check again with hashtable just in case another 1404 // thread created a handler since we last checked 1405 handler2 = handlers.get(protocol); 1406 1407 if (handler2 != null) { 1408 return handler2; 1409 } 1410 1411 // Check with factory if another thread set a 1412 // factory since our last check 1413 if (!checkedWithFactory && (fac = factory) != null) { 1414 handler2 = fac.createURLStreamHandler(protocol); 1415 } 1416 1417 if (handler2 != null) { 1418 // The handler from the factory must be given more 1419 // importance. Discard the default handler that 1420 // this thread created. 1421 handler = handler2; 1422 } 1423 } 1424 1425 // Insert this handler into the hashtable 1426 if (handler != null) { 1427 handlers.put(protocol, handler); 1428 } 1429 } 1430 1431 return handler; 1432 } 1433 1434 /** 1435 * @serialField protocol String 1436 * 1437 * @serialField host String 1438 * 1439 * @serialField port int 1440 * 1441 * @serialField authority String 1442 * 1443 * @serialField file String 1444 * 1445 * @serialField ref String 1446 * 1447 * @serialField hashCode int 1448 * 1449 */ 1450 private static final ObjectStreamField[] serialPersistentFields = { | 1376 boolean checkedWithFactory = false; 1377 1378 if (isOverrideable(protocol) && jdk.internal.misc.VM.isBooted()) { 1379 // Use the factory (if any). Volatile read makes 1380 // URLStreamHandlerFactory appear fully initialized to current thread. 1381 fac = factory; 1382 if (fac != null) { 1383 handler = fac.createURLStreamHandler(protocol); 1384 checkedWithFactory = true; 1385 } 1386 1387 if (handler == null && !protocol.equalsIgnoreCase("jar")) { 1388 handler = lookupViaProviders(protocol); 1389 } 1390 1391 if (handler == null) { 1392 handler = lookupViaProperty(protocol); 1393 } 1394 } 1395 1396 if (handler == null) { 1397 // Try the built-in protocol handler 1398 handler = defaultFactory.createURLStreamHandler(protocol); 1399 } 1400 1401 synchronized (streamHandlerLock) { 1402 URLStreamHandler handler2 = null; 1403 1404 // Check again with hashtable just in case another 1405 // thread created a handler since we last checked 1406 handler2 = handlers.get(protocol); 1407 1408 if (handler2 != null) { 1409 return handler2; 1410 } 1411 1412 // Check with factory if another thread set a 1413 // factory since our last check 1414 if (!checkedWithFactory && (fac = factory) != null) { 1415 handler2 = fac.createURLStreamHandler(protocol); 1416 } 1417 1418 if (handler2 != null) { 1419 // The handler from the factory must be given more 1420 // importance. Discard the default handler that 1421 // this thread created. 1422 handler = handler2; 1423 } 1424 1425 // Insert this handler into the hashtable 1426 if (handler != null) { 1427 handlers.put(protocol, handler); 1428 } 1429 } 1430 return handler; 1431 } 1432 1433 /** 1434 * @serialField protocol String 1435 * 1436 * @serialField host String 1437 * 1438 * @serialField port int 1439 * 1440 * @serialField authority String 1441 * 1442 * @serialField file String 1443 * 1444 * @serialField ref String 1445 * 1446 * @serialField hashCode int 1447 * 1448 */ 1449 private static final ObjectStreamField[] serialPersistentFields = { |