input
stringlengths
205
73.3k
output
stringlengths
64
73.2k
instruction
stringclasses
1 value
#vulnerable code public Archive findMatchingArchive(FetchRequest request) throws IOException { ConsolFun consolFun = request.getConsolFun(); long fetchStart = request.getFetchStart(); long fetchEnd = request.getFetchEnd(); long resolution = request.getRes...
#fixed code public Archive findMatchingArchive(FetchRequest request) throws IOException { ConsolFun consolFun = request.getConsolFun(); long fetchStart = request.getFetchStart(); long fetchEnd = request.getFetchEnd(); long resolution = request.getResolutio...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void release(RrdDb rrdDb) throws IOException { // null pointer should not kill the thread, just ignore it if (rrdDb == null) { return; } RrdEntry ref; try { ref = getEntry(rrdDb.getPath(), false); ...
#fixed code public void release(RrdDb rrdDb) throws IOException { // null pointer should not kill the thread, just ignore it if (rrdDb == null) { return; } RrdEntry ref; try { ref = getEntry(rrdDb.getPath(), false); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testEntriesNeg80To90InRrd() throws IOException, FontFormatException { createGaugeRrd(180); RrdDb rrd = new RrdDb(jrbFileName); for(int i=0; i<170; i++) { long timestamp = startTime + 1 + (i * 60); Sa...
#fixed code @Test public void testEntriesNeg80To90InRrd() throws IOException, FontFormatException { createGaugeRrd(180); RrdDb rrd = RrdDb.getBuilder().setPath(jrbFileName).build(); for(int i=0; i<170; i++) { long timestamp = startTime + 1 + (i * ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void basicUsage() throws IOException { // OSGi metadata is only added for Java8+, so skip this test on Java 7 String javaVersion = System.getProperty("java.version"); assumeThat(javaVersion, not(startsWith((("1.7"))))); ...
#fixed code @Test public void basicUsage() throws IOException { // OSGi metadata is only added for Java8+, so skip this test on Java 7 String javaVersion = System.getProperty("java.version"); assumeThat(javaVersion, not(startsWith((("1.7"))))); RrdDe...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testEntriesNeg55To105InRrd() throws IOException, FontFormatException { createGaugeRrd(165); RrdDb rrd = new RrdDb(jrbFileName); for(int i=0; i<160; i++) { long timestamp = startTime + 1 + (i * 60); S...
#fixed code @Test public void testEntriesNeg55To105InRrd() throws IOException, FontFormatException { createGaugeRrd(165); RrdDb rrd = RrdDb.getBuilder().setPath(jrbFileName).build(); for(int i=0; i<160; i++) { long timestamp = startTime + 1 + (i ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testBackendFactory() throws IOException { RrdNioBackendFactory factory = (RrdNioBackendFactory) RrdBackendFactory.getFactory("NIO"); File rrdfile = testFolder.newFile("testfile"); RrdBackend be = factory.open(rrdfile.getCan...
#fixed code @Test public void testBackendFactory() throws IOException { RrdNioBackendFactory factory = (RrdNioBackendFactory) RrdBackendFactory.getFactory("NIO"); File rrdfile = testFolder.newFile("testfile"); RrdBackend be = factory.open(rrdfile.getCanonical...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testOneEntryInRrd() throws IOException, FontFormatException { createGaugeRrd(100); RrdDb rrd = new RrdDb(jrbFileName); long nowSeconds = new Date().getTime(); long fiveMinutesAgo = nowSeconds - (5 * 60); Samp...
#fixed code @Test public void testOneEntryInRrd() throws IOException, FontFormatException { createGaugeRrd(100); RrdDb rrd = RrdDb.getBuilder().setPath(jrbFileName).build(); long nowSeconds = new Date().getTime(); long fiveMinutesAgo = nowSeconds - (5 ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testEntriesNeg80To80InRrd() throws IOException, FontFormatException { createGaugeRrd(180); RrdDb rrd = new RrdDb(jrbFileName); for(int i=0; i<160; i++) { long timestamp = startTime + 1 + (i * 60); Sa...
#fixed code @Test public void testEntriesNeg80To80InRrd() throws IOException, FontFormatException { createGaugeRrd(180); RrdDb rrd = RrdDb.getBuilder().setPath(jrbFileName).build(); for(int i=0; i<160; i++) { long timestamp = startTime + 1 + (i * ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void shouldGetPlaylistsForUser_async() throws Exception { final String accessToken = "someAccessToken"; final Api api = Api.builder().build(); final UserPlaylistsRequest request = api .getPlaylistsForUser("wizzler") .acc...
#fixed code @Test public void shouldGetPlaylistsForUser_async() throws Exception { final String accessToken = "someAccessToken"; final Api api = Api.builder().build(); final UserPlaylistsRequest request = api .getPlaylistsForUser("wizzler") .accessTok...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void shouldCreateFeaturedPlaylistsRequest() { final String accessToken = "myAccessToken"; final Api api = Api.builder() .accessToken(accessToken) .build(); Calendar calendar = Calendar.getInstance(); calendar.set(2014, 11,...
#fixed code @Test public void shouldCreateFeaturedPlaylistsRequest() { final String accessToken = "myAccessToken"; final Api api = Api.builder() .accessToken(accessToken) .build(); Calendar calendar = Calendar.getInstance(); calendar.set(2014, Calendar....
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void shouldGetAlbumResult_sync() throws Exception { final Api api = Api.DEFAULT_API; final HttpManager mockedHttpManager = TestUtil.MockedHttpManager.returningJson("album.json"); final AlbumRequest request = api.album().id("7e0ij2fpWaxOEHv5fUYZ...
#fixed code @Test public void shouldGetAlbumResult_sync() throws Exception { final Api api = Api.DEFAULT_API; final HttpManager mockedHttpManager = TestUtil.MockedHttpManager.returningJson("album.json"); final AlbumRequest request = api.getAlbum("7e0ij2fpWaxOEHv5fUYZjd").htt...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void shouldGetPlaylistsForUser_sync() throws Exception { final String accessToken = "myVeryLongAccessToken"; final Api api = Api.builder().build(); final UserPlaylistsRequest request = api .getPlaylistsForUser("wizzler") ...
#fixed code @Test public void shouldGetPlaylistsForUser_sync() throws Exception { final String accessToken = "myVeryLongAccessToken"; final Api api = Api.builder().build(); final UserPlaylistsRequest request = api .getPlaylistsForUser("wizzler") .acce...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private static String readFromFile(File file) throws IOException { Reader reader = new FileReader(file); CharBuffer charBuffer = CharBuffer.allocate(MAX_TEST_DATA_FILE_SIZE); reader.read(charBuffer); charBuffer.position(0); return charBuffer.toString()...
#fixed code private static String readFromFile(File file) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF8")); StringBuilder out = new StringBuilder(); String line; while ((line = in.readLine()) != null) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void shouldCreateFeaturedPlaylistsRequest() { final String accessToken = "myAccessToken"; final Api api = Api.builder() .accessToken(accessToken) .build(); Calendar calendar = Calendar.getInstance(); calendar.set(2014, 11,...
#fixed code @Test public void shouldCreateFeaturedPlaylistsRequest() { final String accessToken = "myAccessToken"; final Api api = Api.builder() .accessToken(accessToken) .build(); Calendar calendar = Calendar.getInstance(); calendar.set(2014, Calendar....
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private static String readFromFile(File file) throws IOException { Reader reader = new FileReader(file); CharBuffer charBuffer = CharBuffer.allocate(MAX_TEST_DATA_FILE_SIZE); reader.read(charBuffer); charBuffer.position(0); return charBuffer.toString()...
#fixed code private static String readFromFile(File file) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF8")); StringBuilder out = new StringBuilder(); String line; while ((line = in.readLine()) != null) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void bindScope(Class<? extends Annotation> annotationType, Scope scope) { ensureNotCreated(); Scope existing = scopes.get(nonNull(annotationType, "annotation type")); if (existing != null) { addError(source(), ErrorMessages.DUPLICATE_SCOPES,...
#fixed code public void bindScope(Class<? extends Annotation> annotationType, Scope scope) { Scope existing = scopes.get(nonNull(annotationType, "annotation type")); if (existing != null) { addError(source(), ErrorMessages.DUPLICATE_SCOPES, existing, annotatio...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public <T> LinkedBindingBuilderImpl<T> link(Key<T> key) { ensureNotCreated(); LinkedBindingBuilderImpl<T> builder = new LinkedBindingBuilderImpl<T>(this, key).from(source()); linkedBindingBuilders.add(builder); return builder; } ...
#fixed code public <T> LinkedBindingBuilderImpl<T> link(Key<T> key) { LinkedBindingBuilderImpl<T> builder = new LinkedBindingBuilderImpl<T>(this, key).from(source()); linkedBindingBuilders.add(builder); return builder; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code void putBinding(Binding<?> binding) { Key<?> key = binding.getKey(); Map<Key<?>, Binding<?>> bindings = container.internalBindings(); Binding<?> original = bindings.get(key); if (bindings.containsKey(key)) { addError(binding.getSource(), ErrorMessage...
#fixed code void addError(Object source, String message, Object... arguments) { new ConfigurationErrorHandler(source).handle(message, arguments); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public <T> BindingBuilderImpl<T> bind(Key<T> key) { ensureNotCreated(); BindingBuilderImpl<T> builder = new BindingBuilderImpl<T>(this, key, source()); bindingBuilders.add(builder); return builder; } #location 2 ...
#fixed code public <T> BindingBuilderImpl<T> bind(Key<T> key) { BindingBuilderImpl<T> builder = new BindingBuilderImpl<T>(this, key, source()); bindingBuilders.add(builder); return builder; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code java.util.List<com.google.inject.spi.DependencyAndSource> getDependencyChain() { com.google.common.collect.ImmutableList.Builder<com.google.inject.spi.DependencyAndSource> builder = com.google.common.collect.ImmutableList.builder(); for (int i = 0; i < dep...
#fixed code InternalContext(InjectorOptions options, Object[] toClear) { this.options = options; this.toClear = toClear; this.enterCount = 1; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public ConstantBindingBuilderImpl bindConstant( Class<? extends Annotation> annotationType) { ensureNotCreated(); return bind(source(), Key.strategyFor(annotationType)); } #location 3 #vulnerability...
#fixed code public ConstantBindingBuilderImpl bindConstant( Class<? extends Annotation> annotationType) { return bind(source(), Key.strategyFor(annotationType)); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void testReturnDelegateCookies() { Cookie[] cookies = new Cookie[]{ new Cookie("testName1", TEST_VALUE_1), new Cookie("testName2", "testValue2") }; HttpServletRequest delegate = createMock(HttpServletRequest.class); expect(delegate.g...
#fixed code public void testReturnDelegateCookies() { Cookie[] cookies = new Cookie[]{ new Cookie("testName1", TEST_VALUE_1), new Cookie("testName2", "testValue2") }; HttpServletRequest delegate = createMock(HttpServletRequest.class); expect(delegate.getCook...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public ConstantBindingBuilderImpl bindConstant(Annotation annotation) { ensureNotCreated(); return bind(source(), Key.strategyFor(annotation)); } #location 2 #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code public ConstantBindingBuilderImpl bindConstant(Annotation annotation) { return bind(source(), Key.strategyFor(annotation)); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code void putBinding(Binding<?> binding) { Key<?> key = binding.getKey(); Map<Key<?>, Binding<?>> bindings = container.internalBindings(); Binding<?> original = bindings.get(key); // Binding to Locator<?> is not allowed. if (key.getRawType().equals(Locator...
#fixed code void addError(Object source, String message, Object... arguments) { configurationErrorHandler.handle(source, message, arguments); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void bindInterceptor(Matcher<? super Class<?>> classMatcher, Matcher<? super Method> methodMatcher, MethodInterceptor... interceptors) { ensureNotCreated(); proxyFactoryBuilder.intercept(classMatcher, methodMatcher, interceptors); } ...
#fixed code public void bindInterceptor(Matcher<? super Class<?>> classMatcher, Matcher<? super Method> methodMatcher, MethodInterceptor... interceptors) { proxyFactoryBuilder.intercept(classMatcher, methodMatcher, interceptors); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override protected void doHealthCheck(Health.Builder builder) throws Exception { AdminClient adminClient = null; try { final Status status = healthStatusThreadLocal.get(); //If one of the kafka streams binders (kstream, ktable, globalktable) was down before on...
#fixed code @Override protected void doHealthCheck(Health.Builder builder) throws Exception { AdminClient adminClient = null; try { final Status status = healthStatusThreadLocal.get(); //If one of the kafka streams binders (kstream, ktable, globalktable) was down before on the s...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override protected double evaluateFunction(final Access1D<?> solution) { final MatrixStore<Double> tmpX = this.getMatrixX(); return tmpX.transpose().multiply(this.getMatrixQ().multiply(tmpX)).multiply(0.5).subtract(tmpX.transpose().multiply(this.g...
#fixed code @Override protected double evaluateFunction(final Access1D<?> solution) { final MatrixStore<Double> tmpX = this.getSolutionX(); return tmpX.transpose().multiply(this.getMatrixQ().multiply(tmpX)).multiply(0.5).subtract(tmpX.transpose().multiply(this.getMa...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public MatrixStore<N> getInverse() { if (myInverse == null) { final MatrixStore<N> tmpQ1 = this.getQ1(); final MatrixStore<N> tmpD = this.getD(); final int tmpRowDim = (int) tmpD.countRows(); final int tmpColDim...
#fixed code public MatrixStore<N> getInverse() { return this.getInverse(this.preallocate(new Structure2D() { public long countRows() { return myTransposed ? myBidiagonal.getColDim() : myBidiagonal.getRowDim(); } public long c...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public MatrixStore<N> getInverse(final DecompositionStore<N> preallocated) { if (myInverse == null) { preallocated.fillAll(this.scalar().zero().getNumber()); final PhysicalStore<N> tmpMtrx = preallocated; final MatrixStore<...
#fixed code public MatrixStore<N> getInverse(final DecompositionStore<N> preallocated) { if (myInverse == null) { final MatrixStore<N> tmpQ1 = this.getQ1(); final Array1D<Double> tmpSingulars = this.getSingularValues(); final MatrixStore<N> t...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public MatrixStore<N> getInverse() { if (myInverse == null) { final MatrixStore<N> tmpQ1 = this.getQ1(); final MatrixStore<N> tmpD = this.getD(); final int tmpRowDim = (int) tmpD.countRows(); final int tmpColDim...
#fixed code public MatrixStore<N> getInverse() { return this.getInverse(this.preallocate(new Structure2D() { public long countRows() { return myTransposed ? myBidiagonal.getColDim() : myBidiagonal.getRowDim(); } public long c...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private boolean isFeasible() { boolean retVal = true; final MatrixStore<Double> tmpAEX = this.getAEX(); final MatrixStore<Double> tmpBE = this.getMatrixBE(); for (int i = 0; retVal && (i < tmpBE.countRows()); i++) { if (opti...
#fixed code private boolean isFeasible() { boolean retVal = true; final MatrixStore<Double> tmpSE = this.getSE(); for (int i = 0; retVal && (i < tmpSE.countRows()); i++) { if (!options.slack.isZero(tmpSE.doubleValue(i))) { retVal = fa...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public MatrixStore<N> getInverse(final DecompositionStore<N> preallocated) { if (myInverse == null) { preallocated.fillAll(this.scalar().zero().getNumber()); final PhysicalStore<N> tmpMtrx = preallocated; final MatrixStore<...
#fixed code public MatrixStore<N> getInverse(final DecompositionStore<N> preallocated) { if (myInverse == null) { final MatrixStore<N> tmpQ1 = this.getQ1(); final Array1D<Double> tmpSingulars = this.getSingularValues(); final MatrixStore<N> t...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override protected double evaluateFunction(final Access1D<?> solution) { final MatrixStore<Double> tmpX = this.getX(); return tmpX.transpose().multiply(this.getQ().multiply(tmpX)).multiply(0.5).subtract(tmpX.transpose().multiply(this.getC())).doub...
#fixed code @Override protected double evaluateFunction(final Access1D<?> solution) { final MatrixStore<Double> tmpX = this.getMatrixX(); return tmpX.transpose().multiply(this.getMatrixQ().multiply(tmpX)).multiply(0.5).subtract(tmpX.transpose().multiply(this.getMatr...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public N remove(final long key) { final N tmpOldVal = myStorage.get(key); myStorage.set(key, 0.0); return tmpOldVal; } #location 3 #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code public N remove(final long key) { final int index = myStorage.index(key); final N oldValue = index >= 0 ? myStorage.getInternally(index) : null; myStorage.remove(key, index); return oldValue; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void train(final Access1D<Double> givenInput, final Access1D<Double> targetOutput) { Access1D<Double> current = this.invoke(givenInput); myGradients[0].fillMatching(givenInput); myGradients[myGradients.length - 1].fillMatching(targetOutp...
#fixed code public void train(final Access1D<Double> givenInput, final Access1D<Double> targetOutput) { Access1D<Double> current = this.invoke(givenInput); myGradients[0].fillMatching(givenInput); myGradients[myGradients.length - 1].fillMatching(targetOutput, my...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public MatrixStore<N> getInverse(final DecompositionStore<N> preallocated) { if (myInverse == null) { final MatrixStore<N> tmpQ1 = this.getQ1(); final Array1D<Double> tmpSingulars = this.getSingularValues(); final MatrixStor...
#fixed code public MatrixStore<N> getInverse(final DecompositionStore<N> preallocated) { if (myInverse == null) { final MatrixStore<N> tmpQ1 = this.getQ1(); final Array1D<Double> tmpSingulars = this.getSingularValues(); final MatrixStore<N> t...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(final String[] args) { final Array1D<Double> doubles = Array1D.factory(Primitive32Array.FACTORY).makeFilled(10, new Uniform()); System.out.println(doubles.toString()); final Array1D<Double> rollingMedian = Array1D.PRIMIT...
#fixed code public static void main(final String[] args) { final Array1D<Double> doubles = Array1D.factory(Primitive32Array.FACTORY).makeFilled(10, new Uniform()); System.out.println(doubles.toString()); final Array1D<Double> rollingMedian = Array1D.PRIMITIVE32....
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code void doTestFeedForward(Factory<Double, ?> factory) { int counter = 0; ArtificialNeuralNetwork network = this.getInitialNetwork(factory).get(); for (Data triplet : this.getTestCases()) { if ((triplet.input != null) && (triplet.expec...
#fixed code void doTestFeedForward(final Factory<Double, ?> factory) { int counter = 0; ArtificialNeuralNetwork network = this.getInitialNetwork(factory); NetworkInvoker invoker = network.newInvoker(); for (Data triplet : this.getTestCases()) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public int getRank() { final Array1D<Double> tmpSingularValues = this.getSingularValues(); int retVal = tmpSingularValues.size(); // Tolerance based on min-dim but should be max-dim final double tmpTolerance = retVal * (tmpSingularValue...
#fixed code public int getRank() { final double tolerance = s[0] * this.getDimensionalEpsilon(); int rank = 0; for (int i = 0; i < s.length; i++) { if (s[i] > tolerance) { rank++; } } return rank; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public MatrixStore<N> getInverse(final DecompositionStore<N> preallocated) { if (myInverse == null) { final MatrixStore<N> tmpQ1 = this.getQ1(); final Array1D<Double> tmpSingulars = this.getSingularValues(); final MatrixStor...
#fixed code public MatrixStore<N> getInverse(final DecompositionStore<N> preallocated) { if (myInverse == null) { final MatrixStore<N> tmpQ1 = this.getQ1(); final Array1D<Double> tmpSingulars = this.getSingularValues(); final MatrixStore<N> t...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static MathProgSysModel make(final File file) { final MathProgSysModel retVal = new MathProgSysModel(); String tmpLine; FileSection tmpSection = null; try { final BufferedReader tmpBufferedFileReader = new BufferedR...
#fixed code public static MathProgSysModel make(final File file) { final MathProgSysModel retVal = new MathProgSysModel(); String line; FileSection section = null; try (BufferedReader reader = new BufferedReader(new FileReader(file))) { // ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public boolean isAnyExpressionQuadratic() { boolean retVal = false; String tmpExpressionKey; for (final Iterator<String> tmpIterator = myExpressions.keySet().iterator(); !retVal && tmpIterator.hasNext();) { tmpExpressionKey = tmpIte...
#fixed code public boolean isAnyExpressionQuadratic() { boolean retVal = false; for (Expression value : myExpressions.values()) { retVal |= value.isAnyQuadraticFactorNonZero() && (value.isConstraint() || value.isObjective()); } return retVal...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public MatrixStore<N> getInverse() { if (myInverse == null) { final MatrixStore<N> tmpQ1 = this.getQ1(); final MatrixStore<N> tmpD = this.getD(); final int tmpRowDim = (int) tmpD.countRows(); final int tmpColDim...
#fixed code public MatrixStore<N> getInverse() { return this.getInverse(this.preallocate(new Structure2D() { public long countRows() { return myTransposed ? myBidiagonal.getColDim() : myBidiagonal.getRowDim(); } public long c...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void testXhtmlParsing() throws Exception { Parser parser = new AutoDetectParser(); // Should auto-detect! ContentHandler handler = new BodyContentHandler(); Metadata metadata = new Metadata(); InputStream stream = HtmlParserTest.c...
#fixed code public void testXhtmlParsing() throws Exception { String path = "/test-documents/testXHTML.html"; Metadata metadata = new Metadata(); String content = Tika.parseToString( HtmlParserTest.class.getResourceAsStream(path), metadata); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void extract(InputStream input) throws Exception { // First, extract properties this.reader = new POIFSReader(); this.reader.registerListener(new PropertiesReaderListener(), SummaryInformation.DEFAULT_STREAM_NAME); RereadableInputStream ris = new Rerea...
#fixed code public void extract(InputStream input) throws Exception { RereadableInputStream ris = new RereadableInputStream(input, MEMORY_THRESHOLD); try { // First, extract properties this.reader = new POIFSReader(); this.reader.registerListener(new PropertiesReaderListen...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public String parse(InputStream stream, Metadata metadata) throws IOException, TikaException { StringBuilder sb = new StringBuilder(); BufferedReader br = new BufferedReader(new InputStreamReader(stream)); int charAsInt; whi...
#fixed code public String parse(InputStream stream, Metadata metadata) throws IOException, TikaException { CharsetDetector detector = new CharsetDetector(); // Use the declared character encoding, if available String encoding = metadata.get(Metadata.C...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static Parser getParser(File file, LiusConfig tc) throws IOException, LiusException { String mimeType = MimeTypesUtils.getMimeType(file); ParserConfig pc = tc.getParserConfig(mimeType); String className = pc.getParserClass(); ...
#fixed code public static Parser getParser(File file, LiusConfig tc) throws IOException, LiusException { if(!file.canRead()) { throw new IOException("Cannot read input file " + file.getAbsoluteFile()); } String mimeType = MimeTypesUtils.getMi...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void testClassParsing() throws Exception { Parser parser = new AutoDetectParser(); // Should auto-detect! ContentHandler handler = new BodyContentHandler(); Metadata metadata = new Metadata(); InputStream stream = ClassParserTest....
#fixed code public void testClassParsing() throws Exception { String path = "/test-documents/AutoDetectParser.class"; Metadata metadata = new Metadata(); String content = Tika.parseToString( ClassParserTest.class.getResourceAsStream(path), metadata...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void test() throws IOException { File file = createTestFile(); InputStream is = new BufferedInputStream(new FileInputStream(file)); RereadableInputStream ris = new RereadableInputStream(is, MEMORY_THRESHOLD); try {...
#fixed code public void test() throws IOException { InputStream is = createTestInputStream(); RereadableInputStream ris = new RereadableInputStream(is, MEMORY_THRESHOLD); try { for (int pass = 0; pass < NUM_PASSES; pass++) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void parse( InputStream stream, ContentHandler handler, Metadata metadata) throws IOException, SAXException, TikaException { CharsetDetector detector = new CharsetDetector(); // Use the declared character encoding, if avai...
#fixed code public void parse( InputStream stream, ContentHandler handler, Metadata metadata) throws IOException, SAXException, TikaException { metadata.set(Metadata.CONTENT_TYPE, "text/plain"); // CharsetDetector expects a stream to support marks...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void parse( InputStream stream, ContentHandler handler, Metadata metadata) throws IOException, SAXException, TikaException { SAXParser parser = new SAXParser(); parser.setContentHandler( new TitleExtractingC...
#fixed code public void parse( InputStream stream, ContentHandler handler, Metadata metadata) throws IOException, SAXException, TikaException { // Protect the stream from being closed by CyberNeko stream = new CloseShieldInputStream(stream); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private MagicMatch readMatch(Element element) throws MimeTypeException { String offset = null; String value = null; String mask = null; String type = null; NamedNodeMap attrs = element.getAttributes(); for (int i = 0; i ...
#fixed code private MagicMatch readMatch(Element element) throws MimeTypeException { String offset = null; String value = null; String mask = null; String type = null; NamedNodeMap attrs = element.getAttributes(); for (int i = 0; i < attr...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void parse( InputStream stream, ContentHandler handler, Metadata metadata) throws IOException, SAXException, TikaException { ZipInputStream zip = new ZipInputStream(stream); ZipEntry entry = zip.getNextEntry(); whil...
#fixed code public void parse( InputStream stream, ContentHandler handler, Metadata metadata) throws IOException, SAXException, TikaException { ZipInputStream zip = new ZipInputStream(stream); ZipEntry entry = zip.getNextEntry(); while (ent...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void parse( InputStream stream, ContentHandler handler, Metadata metadata) throws IOException, SAXException, TikaException { // We need buffering to enable MIME magic detection before parsing if (!stream.markSupported()) { ...
#fixed code public void parse( InputStream stream, ContentHandler handler, Metadata metadata) throws IOException, SAXException, TikaException { // We need buffering to enable MIME magic detection before parsing if (!stream.markSupported()) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected String parse(InputStream stream, Iterable<Content> contents) throws IOException, TikaException { StringBuffer sb = new StringBuffer(); BufferedReader br = new BufferedReader(new InputStreamReader(stream)); String line = null...
#fixed code protected String parse(InputStream stream, Iterable<Content> contents) throws IOException, TikaException { StringBuilder sb = new StringBuilder(); BufferedReader br = new BufferedReader(new InputStreamReader(stream)); int charAsInt; ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private static Field findSingleFieldUsingStrategy(FieldMatcherStrategy strategy, Object object, boolean checkHierarchy, Class<?> startClass) { assertObjectInGetInternalStateIsNotNull(object); Field fo...
#fixed code private static Field findSingleFieldUsingStrategy(FieldMatcherStrategy strategy, Object object, boolean checkHierarchy, Class<?> startClass) { assertObjectInGetInternalStateIsNotNull(object); Field foundFie...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public boolean getBooleanSetting(String key) { Boolean result = null; if (this.getSettings().containsKey(key)) { Object foo = this.getSettings().get(key); if (foo instanceof String) { result = Boolean.valueOf((Stri...
#fixed code public boolean getBooleanSetting(String key) { Boolean result = null; if (this.getSettings().containsKey(key)) { Object foo = this.getSettings().get(key); if (foo instanceof String) { result = Boolean.valueOf((String)foo...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void doWrite(Query query) throws Exception { Socket socket = new Socket(host, port); DataOutputStream out = new DataOutputStream( socket.getOutputStream()); BufferedReader inFromServer = new BufferedReader(n...
#fixed code @Override public void doWrite(Query query) throws Exception { Socket socket = new Socket(host, port); DataOutputStream out = new DataOutputStream( socket.getOutputStream()); for (Result result : query.getResults()) { fo...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private String handleTypeName(String typeName) { String[] tokens = typeName.split(","); boolean foundIt = false; for (String token : tokens) { String[] keys = token.split("="); for (String key : keys) { // ...
#fixed code private String handleTypeName(String typeName) { if (getTypeNames() == null && getTypeNames().size() == 0) { return null; } String[] tokens = typeName.split(","); boolean foundIt = false; for (String token : tokens) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void doWrite(Query query) throws Exception { List<String> typeNames = this.getTypeNames(); DatagramSocket socket = new DatagramSocket(); try { for (Result result : query.getResults()) { if (isDebugEnabled()) { log.debug(result.toString()); } ...
#fixed code public void doWrite(Query query) throws Exception { List<String> typeNames = this.getTypeNames(); DatagramSocket socket = (DatagramSocket) pool.borrowObject(this.address); try { for (Result result : query.getResults()) { if (isDebugEnabled()) { log.debug(resu...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override protected void finishOutput() throws IOException { try { this.out.flush(); } catch (IOException e) { log.error("flush failed"); throw e; } // Read and log the response from the serve...
#fixed code @Override protected void finishOutput() throws IOException { }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void processQuery(MBeanServerConnection mbeanServer, Query query) throws Exception { List<Result> resList = new ArrayList<Result>(); ObjectName oName = new ObjectName(query.getObj()); Set<ObjectName> queryNames = mbeanSer...
#fixed code public static void processQuery(MBeanServerConnection mbeanServer, Query query) throws Exception { List<Result> resList = new ArrayList<Result>(); ObjectName oName = new ObjectName(query.getObj()); Set<ObjectName> queryNames = mbeanServer.qu...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public NodeSet eval(final XPContext ctx) { ctx.local = new NodeSet(ctx.local.data.ids(index)[0], ctx); return ctx.local; } #location 3 #vulnerability type NULL_DEREFERENCE
#fixed code @Override public NodeSet eval(final XPContext ctx) { final IndexIterator it = ctx.local.data.ids(index); final IntList il = new IntList(); while(it.more()) { ctx.checkStop(); il.add(it.next()); } ctx.local = new NodeSet(il.finish(), ctx); r...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private IndexIterator getFuzzy(final byte[] tok, final int e) { int[][] ft = null; byte[] to; int dif; int i = 0; final int is = li.readBytes(0, 1L)[0]; int ts = li.readBytes(1L, 2L)[0]; dif = (tok.length - ts < 0) ? ts - tok.length ...
#fixed code private IndexIterator getFuzzy(final byte[] tok, final int e) { int[][] ft = null; byte[] to; int i = 0; final int is = li.readBytes(0, 1L)[0]; int ts = li.readBytes(1L, 2L)[0]; int dif = Math.abs(tok.length - ts); while (i < is && dif > e) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void actionPerformed(final ActionEvent e) { if(e == null) { if(GUIProp.execrt) query(false); return; } final Object source = e.getSource(); int cp = 0; final int cs = panel.getComponentCount(); for(int c = 0; c < cs; c++) if(pa...
#fixed code public void actionPerformed(final ActionEvent e) { if(e == null) { if(GUIProp.execrt) query(false); return; } final Object source = e.getSource(); int cp = 0; final int cs = panel.getComponentCount(); for(int c = 0; c < cs; c++) if(panel.ge...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public NodeSet eval(final XPContext ctx) { ctx.local = new NodeSet(ctx.local.data.ids(index)[0], ctx); return ctx.local; } #location 3 #vulnerability type NULL_DEREFERENCE
#fixed code @Override public NodeSet eval(final XPContext ctx) { final IndexIterator it = ctx.local.data.ids(index); final IntList il = new IntList(); while(it.more()) { ctx.checkStop(); il.add(it.next()); } return ctx.local; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public FTNode next(final XPContext ctx) { final FTPositionFilter tmp = ctx.ftpos; ctx.ftpos = ftpos; final FTNode n1 = calcFTAnd(pex, ctx); /* nod2 = (nex.length > 0 && nod2 == null && more(nex)) ? calcFTAnd(nex, ctx) : nod2; ...
#fixed code @Override public FTNode next(final XPContext ctx) { final FTPositionFilter tmp = ctx.ftpos; ctx.ftpos = ftpos; final FTNode n1 = calcFTAnd(pex, ctx); if (n1 != null && n1.size > 0) { nod2 = (nex.length > 0 && nod2 == null && more(nex)) ? ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private IndexIterator getFuzzy(final byte[] tok, final int e) { int[][] ft = null; byte[] to; int i = 0; final int is = li.readBytes(0, 1L)[0]; int ts = li.readBytes(1L, 2L)[0]; int dif = Math.abs(tok.length - ts); while (i < is && dif > e) {...
#fixed code private IndexIterator getFuzzy(final byte[] tok, final int e) { IndexArrayIterator it = new IndexArrayIterator(0); byte[] to; int i = 0; final int is = li.readBytes(0, 1L)[0]; int ts = li.readBytes(1L, 2L)[0]; int dif = Math.abs(tok.length - ts); w...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public IndexIterator ids(final IndexToken ind) { if(ind.range()) return idRange((RangeToken) ind); final FTTokenizer ft = (FTTokenizer) ind; final byte[] tok = ft.get(); if(ft.fz) { int k = Prop.lserr; if(k == 0) k = Math.max(1...
#fixed code @Override public IndexIterator ids(final IndexToken ind) { if(ind.range()) return idRange((RangeToken) ind); final FTTokenizer ft = (FTTokenizer) ind; final byte[] tok = ft.get(); if(ft.fz) { int k = Prop.lserr; if(k == 0) k = Math.max(1, tok....
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void drawTemperature(final Graphics g, final int level) { // array with all rects of a level // System.out.print("RectCount: " + rectCount + " level " // + level + " size :" // + parentList.size); final RealRect[] tRect = new Real...
#fixed code private void drawTemperature(final Graphics g, final int level) { // array with all rects of a level // System.out.print("RectCount: " + rectCount + " level " // + level + " size :" // + parentList.size); final RealRect[] tRect = new RealRect[r...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void locateMain(final String cmd) throws IOException { GetOpts g = new GetOpts(cmd, "chl:V:", 1); char version = (char) -1; int limit = -1; // get all Options int ch = g.getopt(); while (ch != -1) { switch (ch) { case 'c': ...
#fixed code public void locateMain(final String cmd) throws IOException { GetOpts g = new GetOpts(cmd, "chl:V:", 1); char version = (char) -1; int limit = -1; // get all Options int ch = g.getopt(); while (ch != -1) { switch (ch) { case 'c': ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void releaseTemporaryWriter() { try { IoUtils.closeQuietly(getTemporaryFileWriter()); } catch (IOException e) { // silently skip } if (temporaryFile != null) { temporaryFile.delete(); }...
#fixed code protected void releaseTemporaryWriter() { try { IoUtils.closeQuietly(getTemporaryFileWriter()); } catch (IOException e) { // silently skip } if (temporaryFile != null) { temporaryFile.delete(); } ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code URI newURI(String spec) throws URISyntaxException { String expanded = expand(spec); if (expanded.startsWith(CLASSPATH_PROTOCOL)) { String path = expanded.substring(CLASSPATH_PROTOCOL.length()); URL url = classLoader.getResource(pa...
#fixed code ConfigURIFactory(ClassLoader classLoader, VariablesExpander expander) { this.classLoader = classLoader; this.expander = expander; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(String[] args) throws Exception { SAXParserFactory factory = SAXParserFactory.newInstance(); SAXParser parser = factory.newSAXParser(); InputStream in = XmlSpike.class.getResourceAsStream("Config.xml"); String in...
#fixed code public static void main(String[] args) throws Exception { InputStream in = XmlSpike.class.getResourceAsStream("Config.xml"); Properties props = load(in); File file = new File("target/test-resources/props.xml"); file.getParentFile().mkdirs();...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Before public void before() throws Throwable { synchronized (target) { save(new Properties() {{ setProperty("someValue", "10"); }}); reloadableConfig = ConfigFactory.create(ReloadableConfig.class); ...
#fixed code @Before public void before() throws Throwable { save(new Properties() {{ setProperty("someValue", "10"); }}); reloadableConfig = ConfigFactory.create(ReloadableConfig.class); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testReload() throws Throwable { assertEquals(Integer.valueOf(10), reloadableConfig.someValue()); synchronized (target) { save(new Properties() {{ setProperty("someValue", "20"); }}); ...
#fixed code @Test public void testReload() throws Throwable { assertEquals(Integer.valueOf(10), reloadableConfig.someValue()); save(new Properties() {{ setProperty("someValue", "20"); }}); reloadableConfig.reload(); assertEquals(I...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void shouldReturnTheResourceForAClass() throws IOException { ConfigURLStreamHandler handler = new ConfigURLStreamHandler(SampleConfig.class.getClassLoader(), new SystemVariablesExpander()); ConfigURLStreamHandler spy = sp...
#fixed code @Test public void shouldReturnTheResourceForAClass() throws IOException { ConfigURLStreamHandler handler = new ConfigURLStreamHandler(SampleConfig.class.getClassLoader(), new SystemVariablesExpander()); ConfigURLStreamHandler spy = spy(hand...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code void syncReloadCheck() { if (hotReloadLogic != null && hotReloadLogic.isSync()) hotReloadLogic.checkAndReload(lastLoadTime); } #location 3 #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code PropertiesManager(Class<? extends Config> clazz, Properties properties, ScheduledExecutorService scheduler, Map<?, ?>... imports) { this.clazz = clazz; this.properties = properties; this.imports = imports; handler = new C...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testReload() throws Throwable { assertEquals(Integer.valueOf(10), reloadableConfig.someValue()); synchronized (target) { save(new Properties() {{ setProperty("someValue", "20"); }}); ...
#fixed code @Test public void testReload() throws Throwable { assertEquals(Integer.valueOf(10), reloadableConfig.someValue()); save(new Properties() {{ setProperty("someValue", "20"); }}); reloadableConfig.reload(); assertEquals(I...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code String getProperty(String key) { if (syncHotReload != null) syncHotReload.checkAndReload(lastLoadTime); readLock.lock(); try { return properties.getProperty(key); } finally { readLock.unlock(); ...
#fixed code PropertiesManager(Class<? extends Config> clazz, Properties properties, Map<?, ?>... imports) { this.clazz = clazz; this.properties = properties; this.imports = imports; handler = new ConfigURLStreamHandler(clazz.getClassLoader(), expander); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code static String expandUserHome(String text) { if (text.equals("~")) { return System.getProperty("user.home"); } else if (text.indexOf("~/") == 0 || text.indexOf("file:~/") == 0 || text.indexOf("jar:file:~/") == 0) { String safeHome = System.getProper...
#fixed code static String expandUserHome(String text) { if (text.equals("~")) { return system.getProperty("user.home"); } else if (text.indexOf("~/") == 0 || text.indexOf("file:~/") == 0 || text.indexOf("jar:file:~/") == 0) { String safeHome = syst...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static Properties load(InputStream inputStream) throws ParserConfigurationException, SAXException, IOException { SAXParserFactory factory = SAXParserFactory.newInstance(); factory.setValidating(true); factory.setNamespaceAware(...
#fixed code public static Properties load(InputStream inputStream) throws ParserConfigurationException, SAXException, IOException { SAXParserFactory factory = SAXParserFactory.newInstance(); factory.setValidating(true); factory.setNamespaceAware(true);...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private static void storeJar(File target, String entryName, Properties props) throws IOException { byte[] bytes = toBytes(props); InputStream input = new ByteArrayInputStream(bytes); JarOutputStream output = new JarOutputStream(new FileOutputStre...
#fixed code private static void storeJar(File target, String entryName, Properties props) throws IOException { byte[] bytes = toBytes(props); InputStream input = new ByteArrayInputStream(bytes); try { FileOutputStream fileOutputStream = new FileOutputS...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void save(File target, Properties p) throws IOException { File parent = target.getParentFile(); parent.mkdirs(); if (isWindows()) { p.store(new FileWriter(target), "saved for test"); } else { File tem...
#fixed code public static void save(File target, Properties p) throws IOException { File parent = target.getParentFile(); parent.mkdirs(); if (isWindows()) { store(new FileOutputStream(target), p); } else { File tempFile = createTem...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void multiThreadedReloadTest() throws Throwable { Object lock = new Object(); ReaderThread[] readers = newArray(20, new ReaderThread(reloadableConfig, lock, 100)); WriterThread[] writers = newArray(5, new WriterThread(reloadable...
#fixed code @Test public void multiThreadedReloadTest() throws Throwable { Object lock = new Object(); ReaderThread[] readers = newArray(20, new ReaderThread(reloadableConfig, lock, 100)); WriterThread[] writers = newArray(5, new WriterThread(reloadableConfig...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void saveJar(File target, String entryName, Properties props) throws IOException { byte[] bytes = toBytes(props); InputStream input = new ByteArrayInputStream(bytes); FileOutputStream fos = new FileOutputStream(target); JarO...
#fixed code public static void saveJar(File target, String entryName, Properties props) throws IOException { File parent = target.getParentFile(); parent.mkdirs(); storeJar(target, entryName, props); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void shouldReturnTheResourceForAClass() throws IOException { PropertiesManagerForTest manager = new PropertiesManagerForTest(SampleConfig.class, new Properties(), scheduler, expander); assertEquals(1, manager.getUrls().s...
#fixed code @Test public void shouldReturnTheResourceForAClass() throws IOException { PropertiesManagerForTest manager = new PropertiesManagerForTest(SampleConfig.class, new Properties(), scheduler, expander, loaders); manager.load(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void save(File target, Properties p) throws IOException { File parent = target.getParentFile(); parent.mkdirs(); if (isWindows()) { p.store(new FileWriter(target), "saved for test"); } else { File tem...
#fixed code public static void save(File target, Properties p) throws IOException { File parent = target.getParentFile(); parent.mkdirs(); if (isWindows()) { store(new FileOutputStream(target), p); } else { File tempFile = createTem...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void multiThreadedReloadTest() throws Throwable { Object lock = new Object(); ReaderThread[] readers = newArray(20, new ReaderThread(reloadableConfig, lock, 100)); WriterThread[] writers = newArray(5, new WriterThread(reloadable...
#fixed code @Test public void multiThreadedReloadTest() throws Throwable { Object lock = new Object(); ReaderThread[] readers = newArray(20, new ReaderThread(reloadableConfig, lock, 100)); WriterThread[] writers = newArray(5, new WriterThread(reloadableConfig...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @After public void after() throws Throwable { synchronized (target) { target.delete(); } } #location 3 #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code @After public void after() throws Throwable { target.delete(); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void save(File target, Properties p) throws IOException { File parent = target.getParentFile(); parent.mkdirs(); if (isWindows()) { store(new FileOutputStream(target), p); } else { File tempFile = cre...
#fixed code public static void save(File target, Properties p) throws IOException { File parent = target.getParentFile(); parent.mkdirs(); if (isWindows()) { store(target, p); } else { File tempFile = createTempFile(target.getName()...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code InputStream getInputStream(URL url) throws IOException { URLConnection conn = url.openConnection(); if (conn == null) return null; return conn.getInputStream(); } #location 5 ...
#fixed code LoadersManager() { registerLoader(new PropertiesLoader()); registerLoader(new XMLLoader()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void multiThreadedReloadTest() throws Throwable { Object lock = new Object(); ReaderThread[] readers = newArray(20, new ReaderThread(reloadableConfig, lock, 100)); WriterThread[] writers = newArray(5, new WriterThread(reloadable...
#fixed code @Test public void multiThreadedReloadTest() throws Throwable { Object lock = new Object(); ReaderThread[] readers = newArray(20, new ReaderThread(reloadableConfig, lock, 100)); WriterThread[] writers = newArray(5, new WriterThread(reloadableConfig...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void save(File target, Properties p) throws IOException { File parent = target.getParentFile(); parent.mkdirs(); if (isWindows()) { store(new FileOutputStream(target), p); } else { File tempFile = cre...
#fixed code public static void save(File target, Properties p) throws IOException { File parent = target.getParentFile(); parent.mkdirs(); if (isWindows()) { store(target, p); } else { File tempFile = createTempFile(target.getName()...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void shouldLoadURLFromSpecifiedSource() throws IOException { final URL[] lastURL = { null }; ConfigURLStreamHandler handler = new ConfigURLStreamHandler(SampleConfigWithSource.class.getClassLoader(), new SystemVariablesEx...
#fixed code @Test public void shouldLoadURLFromSpecifiedSource() throws IOException { final URL[] lastURL = { null }; ConfigURLStreamHandler handler = new ConfigURLStreamHandler(SampleConfigWithSource.class.getClassLoader(), new SystemVariablesExpander...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override protected Optional<Instant> dataStamp() { try { HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod(HEAD_METHOD); if (connection.getLastModified() != 0) { ...
#fixed code @Override protected Optional<Instant> dataStamp() { // the URL may not be an HTTP URL try { URLConnection urlConnection = url.openConnection(); if (urlConnection instanceof HttpURLConnection) { HttpURLConnection conn...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public Object execute() { // Configure command before execution introspector.getHystrixProperties() .entrySet() .forEach(entry -> setProperty(entry.getKey(), entry.getValue())); // Ensure our...
#fixed code @Override public Object execute() { // Configure command before execution introspector.getHystrixProperties() .entrySet() .forEach(entry -> setProperty(entry.getKey(), entry.getValue())); // Ensure our inter...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public Object execute() { // Configure command before execution introspector.getHystrixProperties() .entrySet() .forEach(entry -> setProperty(entry.getKey(), entry.getValue())); // Ensure our...
#fixed code @Override public Object execute() { // Configure command before execution introspector.getHystrixProperties() .entrySet() .forEach(entry -> setProperty(entry.getKey(), entry.getValue())); // Ensure our inter...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public Object execute() { // Configure command before execution introspector.getHystrixProperties() .entrySet() .forEach(entry -> setProperty(entry.getKey(), entry.getValue())); // Record sta...
#fixed code @Override public Object execute() { // Configure command before execution introspector.getHystrixProperties() .entrySet() .forEach(entry -> setProperty(entry.getKey(), entry.getValue())); // Ensure our inter...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override protected Optional<Instant> dataStamp() { try { HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod(HEAD_METHOD); if (connection.getLastModified() != 0) { ...
#fixed code @Override protected Optional<Instant> dataStamp() { // the URL may not be an HTTP URL try { URLConnection urlConnection = url.openConnection(); if (urlConnection instanceof HttpURLConnection) { HttpURLConnection conn...
Below is the vulnerable code, please generate the patch based on the following information.