Source:
<code><START> private <D extends AssetData> D loadAssetData(AssetUri uri, boolean logErrors) { <END> if (!uri.isValid()) { return null; } List<URL> urls = getAssetURLs(uri); if (urls.size() == 0) { if (logErrors) { logger.warn("Unable to resolve asset: {}", uri); } return null; } for (URL url : urls) { int extensionIndex = url.toString().lastIndexOf('.'); if (extensionIndex == -1) { continue; } String extension = url.toString().substring(extensionIndex + 1).toLowerCase(Locale.ENGLISH); Map<String, AssetLoader<?>> extensionMap = assetLoaders.get(uri.getAssetType()); if (extensionMap == null) { continue; } AssetLoader<?> loader = extensionMap.get(extension); if (loader == null) { continue; } Module module = moduleManager.getActiveModule(uri.getNormalisedModuleName()); List<URL> deltas; if (uri.getAssetType().isDeltaSupported()) { deltas = Lists.newArrayList(); for (Module deltaModule : moduleManager.getActiveModulesOrderedByDependency()) { AssetSource source = assetSources.get(deltaModule.getId()); if (source != null) { deltas.addAll(source.getDelta(uri)); } } } else { deltas = Collections.emptyList(); } try (InputStream stream = AccessController.doPrivileged(new PrivilegedOpenStream(url))) { urls.remove(url); urls.add(0, url); return (D) loader.load(module, stream, urls, deltas); } catch (PrivilegedActionException e) { logger.error("Error reading asset {}", uri, e.getCause()); return null; } catch (IOException ioe) { logger.error("Error reading asset {}", uri, ioe); return null; } } logger.warn("Unable to resolve asset: {}", uri); return null; }</code><technical_language>I feel a generic return influenced inputs is a bad idea. is prone issues return is a D, else. I a bug in Java compiler this stage (specifically a mismatch eclipse compiler java compiler handled them). I recommend Class<D> of arguments, class.cast() (D) handle cast out (and checking result is a D returning null if match)</technical_language>

Target:
private AssetData loadAssetData(AssetUri uri, boolean logErrors) { if (!uri.isValid()) { return null; } List<URL> urls = getAssetURLs(uri); if (urls.size() == 0) { if (logErrors) { logger.warn("Unable to resolve asset: {}", uri); } return null; } for (URL url : urls) { int extensionIndex = url.toString().lastIndexOf('.'); if (extensionIndex == -1) { continue; } String extension = url.toString().substring(extensionIndex + 1).toLowerCase(Locale.ENGLISH); Map<String, AssetLoader<?>> extensionMap = assetLoaders.get(uri.getAssetType()); if (extensionMap == null) { continue; } AssetLoader<?> loader = extensionMap.get(extension); if (loader == null) { continue; } Module module = moduleManager.getActiveModule(uri.getNormalisedModuleName()); List<URL> deltas; if (uri.getAssetType().isDeltaSupported()) { deltas = Lists.newArrayList(); for (Module deltaModule : moduleManager.getActiveModulesOrderedByDependency()) { AssetSource source = assetSources.get(deltaModule.getId()); if (source != null) { deltas.addAll(source.getDelta(uri)); } } } else { deltas = Collections.emptyList(); } try (InputStream stream = AccessController.doPrivileged(new PrivilegedOpenStream(url))) { urls.remove(url); urls.add(0, url); return loader.load(module, stream, urls, deltas); } catch (PrivilegedActionException e) { logger.error("Error reading asset {}", uri, e.getCause()); return null; } catch (IOException ioe) { logger.error("Error reading asset {}", uri, ioe); return null; } } logger.warn("Unable to resolve asset: {}", uri); return null; }