#vulnerable code 
                                public String injectVersion(String resourcePath) {
        URL resourceUrl = getResourceUrl(resourcePath);
        try {
            long lastModified = resourceUrl.openConnection().getLastModified();

            // check for extension
            int extensionAt = resourcePath.lastIndexOf('.');

            StringBuilder versionedResourcePath = new StringBuilder();

            if (extensionAt == -1) {
                versionedResourcePath.append(resourcePath);
                versionedResourcePath.append("-ver-").append(lastModified);
            } else {
                versionedResourcePath.append(resourcePath.substring(0, extensionAt));
                versionedResourcePath.append("-ver-").append(lastModified);
                versionedResourcePath.append(resourcePath.substring(extensionAt, resourcePath.length()));
            }

            log.trace("Inject version in resource path: '{}' => '{}'", resourcePath, versionedResourcePath);

            return versionedResourcePath.toString();
        } catch (IOException e) {
            throw new PippoRuntimeException("Failed to read lastModified property for {}", e, resourceUrl);
        }
    } 
                            #location 4 
                            #vulnerability type RESOURCE_LEAK
#fixed code
                                public String injectVersion(String resourcePath) {
        String version = getResourceVersion(resourcePath);
        if (StringUtils.isNullOrEmpty(version)) {
            // unversioned, pass-through resource path
            return resourcePath;
        }

        // check for extension
        int extensionAt = resourcePath.lastIndexOf('.');

        StringBuilder versionedResourcePath = new StringBuilder();

        if (extensionAt == -1) {
            versionedResourcePath.append(resourcePath);
            versionedResourcePath.append("-ver-").append(version);
        } else {
            versionedResourcePath.append(resourcePath.substring(0, extensionAt));
            versionedResourcePath.append("-ver-").append(version);
            versionedResourcePath.append(resourcePath.substring(extensionAt, resourcePath.length()));
        }

        log.trace("Inject version in resource path: '{}' => '{}'", resourcePath, versionedResourcePath);

        return versionedResourcePath.toString();
    }