output
stringlengths
64
73.2k
input
stringlengths
208
73.3k
instruction
stringclasses
1 value
#fixed code @Test /** * Test that checks that concurrent requests to RefreshingOAuth2CredentialsInterceptor refresh * logic doesn't cause hanging behavior. Specifically, when an Expired condition occurs it * triggers a call to syncRefresh() which potentially waits for refresh ...
#vulnerable code @Test /** * Test that checks that concurrent requests to RefreshingOAuth2CredentialsInterceptor refresh * logic doesn't cause hanging behavior. Specifically, when an Expired condition occurs it * triggers a call to syncRefresh() which potentially waits for re...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testRetyableCheckAndMutateRow() throws Exception { final CheckAndMutateRowRequest request = CheckAndMutateRowRequest.getDefaultInstance(); when(mockFuture.get()).thenReturn(CheckAndMutateRowResponse.getDefaultInstance()); underTest.checkAndMutate...
#vulnerable code @Test public void testRetyableCheckAndMutateRow() throws InterruptedException { final CheckAndMutateRowRequest request = CheckAndMutateRowRequest.getDefaultInstance(); final AtomicBoolean done = new AtomicBoolean(false); executor.submit(new Callable<Void>(){...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testRefreshAfterStale() throws Exception { underTest = new RefreshingOAuth2CredentialsInterceptor(executorService, credentials); final AccessToken staleToken = new AccessToken("stale", new Date(HeaderCacheElement.TOKEN_STALENESS_MS + 1)); Access...
#vulnerable code @Test public void testRefreshAfterStale() throws Exception { underTest = new RefreshingOAuth2CredentialsInterceptor(executorService, credentials); underTest.rateLimiter.setRate(100000); final AccessToken staleToken = new AccessToken("stale", new Date(Header...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testRefreshAfterStale() throws Exception { underTest = new RefreshingOAuth2CredentialsInterceptor(executorService, credentials); final AccessToken staleToken = new AccessToken("stale", new Date(HeaderCacheElement.TOKEN_STALENESS_MS + 1)); Access...
#vulnerable code @Test public void testRefreshAfterStale() throws Exception { underTest = new RefreshingOAuth2CredentialsInterceptor(executorService, credentials); underTest.rateLimiter.setRate(100000); final AccessToken staleToken = new AccessToken("stale", new Date(Header...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testPartialResults() throws Exception { byte[] key1 = randomBytes(8); byte[] key2 = randomBytes(8); FlatRow response1 = FlatRow.newBuilder() .withRowKey(ByteString.copyFrom(key1)) .addCell( new Cell...
#vulnerable code @Test public void testPartialResults() throws Exception { byte[] key1 = randomBytes(8); byte[] key2 = randomBytes(8); FlatRow response1 = FlatRow.newBuilder() .withRowKey(ByteString.copyFrom(key1)) .addCell( ne...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testSyncRefresh() throws IOException { Mockito.when(mockCredentials.refreshAccessToken()).thenReturn( new AccessToken("", new Date(HeaderCacheElement.TOKEN_STALENESS_MS + 1))); underTest = new RefreshingOAuth2CredentialsInterceptor(executorSe...
#vulnerable code @Test public void testSyncRefresh() throws IOException { initialize(HeaderCacheElement.TOKEN_STALENESS_MS + 1); Assert.assertEquals(CacheState.Good, underTest.headerCache.getCacheState()); Assert.assertFalse(underTest.isRefreshing()); } ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test /* * Test that checks that concurrent requests to RefreshingOAuth2CredentialsInterceptor refresh * logic doesn't cause hanging behavior. Specifically, when an Expired condition occurs it * triggers a call to syncRefresh() which potentially waits for refresh th...
#vulnerable code @Test /* * Test that checks that concurrent requests to RefreshingOAuth2CredentialsInterceptor refresh * logic doesn't cause hanging behavior. Specifically, when an Expired condition occurs it * triggers a call to syncRefresh() which potentially waits for refr...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void flush() throws IOException { // If there is a bulk mutation in progress, then send it. if (bulkMutation != null) { try { bulkMutation.flush(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw ne...
#vulnerable code public void flush() throws IOException { // If there is a bulk mutation in progress, then send it. if (bulkMutation != null) { try { bulkMutation.flush(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); th...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test /** * Test that checks that concurrent requests to RefreshingOAuth2CredentialsInterceptor refresh * logic doesn't cause hanging behavior. Specifically, when an Expired condition occurs it * triggers a call to syncRefresh() which potentially waits for refresh ...
#vulnerable code @Test /** * Test that checks that concurrent requests to RefreshingOAuth2CredentialsInterceptor refresh * logic doesn't cause hanging behavior. Specifically, when an Expired condition occurs it * triggers a call to syncRefresh() which potentially waits for re...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testStaleAndExpired() throws IOException { long expiration = HeaderCacheElement.TOKEN_STALENESS_MS + 1; initialize(expiration); Assert.assertEquals(CacheState.Good, underTest.getCacheState()); long startTime = 2L; setTimeInMillieconds(sta...
#vulnerable code @Test public void testStaleAndExpired() throws IOException { long expiration = HeaderCacheElement.TOKEN_STALENESS_MS + 1; initialize(expiration); Assert.assertEquals(CacheState.Good, underTest.headerCache.getCacheState()); long startTime = 2L; setTim...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testOptionsAreConstructedWithValidInput() throws IOException { configuration.set(BigtableOptionsFactory.BIGTABLE_HOST_KEY, TEST_HOST); configuration.setBoolean(BigtableOptionsFactory.BIGTABLE_USE_SERVICE_ACCOUNTS_KEY, false); configuration.setBoo...
#vulnerable code @Test public void testOptionsAreConstructedWithValidInput() throws IOException { configuration.set(BigtableOptionsFactory.BIGTABLE_HOST_KEY, TEST_HOST); configuration.setBoolean(BigtableOptionsFactory.BIGTABLE_USE_SERVICE_ACCOUNTS_KEY, false); configuration....
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testRetyableCheckAndMutateRow() throws Exception { final CheckAndMutateRowRequest request = CheckAndMutateRowRequest.getDefaultInstance(); when(mockFuture.get()).thenReturn(CheckAndMutateRowResponse.getDefaultInstance()); underTest.checkAndMutate...
#vulnerable code @Test public void testRetyableCheckAndMutateRow() throws InterruptedException { final CheckAndMutateRowRequest request = CheckAndMutateRowRequest.getDefaultInstance(); final AtomicBoolean done = new AtomicBoolean(false); executor.submit(new Callable<Void>(){...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void onClose(Status status, Metadata trailers) { if (status.getCode() == Status.Code.CANCELLED && status.getDescription() != null && status.getDescription().contains(TIMEOUT_CANCEL_MSG)) { // If this was canceled because of handleTim...
#vulnerable code @Override public void onClose(Status status, Metadata trailers) { if (status.getCode() == Status.Code.CANCELLED && status.getDescription().contains(TIMEOUT_CANCEL_MSG)) { // If this was canceled because of handleTimeout(). The cancel is immediately ret...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test /* * Test that checks that concurrent requests to RefreshingOAuth2CredentialsInterceptor refresh * logic doesn't cause hanging behavior. Specifically, when an Expired condition occurs it * triggers a call to syncRefresh() which potentially waits for refresh th...
#vulnerable code @Test /* * Test that checks that concurrent requests to RefreshingOAuth2CredentialsInterceptor refresh * logic doesn't cause hanging behavior. Specifically, when an Expired condition occurs it * triggers a call to syncRefresh() which potentially waits for refr...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testMutateRowPredicate() { Predicate<MutateRowRequest> defaultPredicate = BigtableDataGrpcClient.IS_RETRYABLE_MUTATION; createClient(true); Predicate<MutateRowRequest> allowNoTimestampsPredicate = predicates.get(BigtableServiceGrpc.METHOD...
#vulnerable code @Test public void testMutateRowPredicate() { Predicate<MutateRowRequest> predicate = BigtableDataGrpcClient.IS_RETRYABLE_MUTATION; assertFalse(predicate.apply(null)); MutateRowRequest.Builder request = MutateRowRequest.newBuilder(); assertTrue(predicate...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test /* * Test that checks that concurrent requests to RefreshingOAuth2CredentialsInterceptor refresh * logic doesn't cause hanging behavior. Specifically, when an Expired condition occurs it * triggers a call to syncRefresh() which potentially waits for refresh th...
#vulnerable code @Test /* * Test that checks that concurrent requests to RefreshingOAuth2CredentialsInterceptor refresh * logic doesn't cause hanging behavior. Specifically, when an Expired condition occurs it * triggers a call to syncRefresh() which potentially waits for refr...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testSyncRefresh() throws IOException { initialize(HeaderCacheElement.TOKEN_STALENESS_MS + 1); Assert.assertEquals(CacheState.Good, underTest.headerCache.getCacheState()); Assert.assertFalse(underTest.isRefreshing()); }
#vulnerable code @Test public void testSyncRefresh() throws IOException { initialize(HeaderCacheElement.TOKEN_STALENESS_MS + 1); Assert.assertEquals(CacheState.Good, underTest.headerCache.getCacheState()); } #location 3 ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testBatchBulkGets() throws Exception { final List<Get> gets = new ArrayList<>(10); final List<ApiFuture<FlatRow>> expected = new ArrayList<>(10); gets.add(new Get(Bytes.toBytes("key0"))); expected.add(ApiFutures.<FlatRow>immediateFuture(null...
#vulnerable code @Test public void testBatchBulkGets() throws Exception { final List<Get> gets = new ArrayList<>(10); final List<ApiFuture<FlatRow>> expected = new ArrayList<>(10); gets.add(new Get(Bytes.toBytes("key0"))); expected.add(ApiFutures.<FlatRow>immediateFutur...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void setMessageCompression(boolean enable) { throw new UnsupportedOperationException("setMessageCompression()"); }
#vulnerable code @Override public void setMessageCompression(boolean enable) { call.setMessageCompression(enable); } #location 3 #vulnerability type THREAD_SAFETY_VIOLATION
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void modifyTable(TableName tableName, TableDescriptor tableDescriptor) throws IOException { super.modifyTable(tableName, new HTableDescriptor(tableDescriptor)); }
#vulnerable code @Override public void modifyTable(TableName tableName, TableDescriptor tableDescriptor) throws IOException { if (isTableAvailable(tableName)) { TableDescriptor currentTableDescriptor = getTableDescriptor(tableName); List<Modification> modifications = new...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void onClose(Status status, Metadata trailers) { synchronized (callLock) { call = null; } rpcTimerContext.close(); // OK if (status.isOk()) { if (onOK(trailers)) { operationTimerContext.close(); } } else { ...
#vulnerable code @Override public void onClose(Status status, Metadata trailers) { synchronized (callLock) { call = null; } rpcTimerContext.close(); Status.Code code = status.getCode(); // OK if (code == Status.Code.OK) { if (onOK()) { opera...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testChannelsAreRoundRobinned() throws IOException { MockChannelFactory factory = new MockChannelFactory(); MethodDescriptor descriptor = mock(MethodDescriptor.class); MockitoAnnotations.initMocks(this); ChannelPool pool = new ChannelPool(null...
#vulnerable code @Test public void testChannelsAreRoundRobinned() throws IOException { MockChannelFactory factory = new MockChannelFactory(); MethodDescriptor descriptor = mock(MethodDescriptor.class); MockitoAnnotations.initMocks(this); ChannelPool pool = new ChannelPoo...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testRefreshAfterFailure() throws Exception { underTest = new RefreshingOAuth2CredentialsInterceptor(executorService, credentials); final AccessToken accessToken = new AccessToken("hi", new Date(HeaderCacheElement.TOKEN_STALENESS_MS + 1)); //noi...
#vulnerable code @Test public void testRefreshAfterFailure() throws Exception { underTest = new RefreshingOAuth2CredentialsInterceptor(executorService, credentials); underTest.rateLimiter.setRate(100000); final AccessToken accessToken = new AccessToken("hi", new Date(Header...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testCBC_UserAgentUsingPlainTextNegotiation() throws Exception{ ServerSocket serverSocket = new ServerSocket(0); final int availablePort = serverSocket.getLocalPort(); serverSocket.close(); //Creates non-ssl server. createServer(available...
#vulnerable code @Test public void testCBC_UserAgentUsingPlainTextNegotiation() throws Exception{ ServerSocket serverSocket = new ServerSocket(0); final int availablePort = serverSocket.getLocalPort(); serverSocket.close(); //Creates non-ssl server. createServer(ava...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @SuppressWarnings("unchecked") @Override public void run() { try { // restart the clock. synchronized (callLock) { super.run(); // pre-fetch one more result, for performance reasons. adapter.request(1); if (rowObserver instanc...
#vulnerable code @SuppressWarnings("unchecked") @Override public void run() { try { // restart the clock. this.rowMerger = new RowMerger(rowObserver); adapter = new CallToStreamObserverAdapter(); synchronized (callLock) { super.run(); // pre...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void retryOnTimeout(ScanTimeoutException rte) throws BigtableRetriesExhaustedException { LOG.info("The client could not get a response in %d ms. Retrying the scan.", retryOptions.getReadPartialRowTimeoutMillis()); // Cancel the existing rpc. cancel(TI...
#vulnerable code private void retryOnTimeout(ScanTimeoutException rte) throws BigtableRetriesExhaustedException { LOG.info("The client could not get a response in %d ms. Retrying the scan.", retryOptions.getReadPartialRowTimeoutMillis()); // Cancel the existing rpc. can...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void onClose(Status status, Metadata trailers) { try (Scope scope = TRACER.withSpan(operationSpan)) { callWrapper.resetCall(); rpcTimerContext.close(); // OK if (status.isOk()) { if (onOK(trailers)) { finalizeStat...
#vulnerable code @Override public void onClose(Status status, Metadata trailers) { try (Scope scope = TRACER.withSpan(operationSpan)) { synchronized (callLock) { call = NULL_CALL; } rpcTimerContext.close(); // OK if (status.isOk()) { if ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static Credentials getCredentials(CredentialOptions options) throws IOException, GeneralSecurityException { return patchCredentials(getCredentialsInner(options)); }
#vulnerable code public static Credentials getCredentials(CredentialOptions options) throws IOException, GeneralSecurityException { switch (options.getCredentialType()) { case DefaultCredentials: return getApplicationDefaultCredential(); case P12: P12...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void awaitCompletion() throws InterruptedException { boolean performedWarning = false; lock.lock(); try { while (!isFlushed()) { flushedCondition.await(finishWaitMillis, TimeUnit.MILLISECONDS); long now = clock.nanoTime(); if (...
#vulnerable code public void awaitCompletion() throws InterruptedException { boolean performedWarning = false; lock.lock(); try { while (!isFlushed()) { flushedCondition.await(finishWaitMillis, TimeUnit.MILLISECONDS); long now = clock.nanoTime(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testRefreshAfterStale() throws Exception { underTest = new RefreshingOAuth2CredentialsInterceptor(executorService, credentials); final AccessToken staleToken = new AccessToken("stale", new Date(HeaderCacheElement.TOKEN_STALENESS_MS + 1)); Access...
#vulnerable code @Test public void testRefreshAfterStale() throws Exception { underTest = new RefreshingOAuth2CredentialsInterceptor(executorService, credentials); underTest.rateLimiter.setRate(100000); final AccessToken staleToken = new AccessToken("stale", new Date(Header...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @SuppressWarnings("unchecked") @Override public void run() { try { // restart the clock. synchronized (callLock) { super.run(); // pre-fetch one more result, for performance reasons. adapter.request(1); if (rowObserver instanc...
#vulnerable code @SuppressWarnings("unchecked") @Override public void run() { try { // restart the clock. this.rowMerger = new RowMerger(rowObserver); adapter = new CallToStreamObserverAdapter(); synchronized (callLock) { super.run(); // pre...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testBatchBulkGets() throws Exception { final List<Get> gets = new ArrayList<>(10); final List<ApiFuture<Result>> expected = new ArrayList<>(10); gets.add(new Get(Bytes.toBytes("key0"))); expected.add(ApiFutures.<Result>immediateFuture(null))...
#vulnerable code @Test public void testBatchBulkGets() throws Exception { final List<Get> gets = new ArrayList<>(10); final List<ApiFuture<FlatRow>> expected = new ArrayList<>(10); gets.add(new Get(Bytes.toBytes("key0"))); expected.add(ApiFutures.<FlatRow>immediateFutur...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testPartialResults() throws Exception { when(mockBigtableApi.getDataClient()).thenReturn(mockDataClientWrapper); when(mockDataClientWrapper.createBulkRead(isA(String.class))).thenReturn(mockBulkRead); byte[] key1 = randomBytes(8); byte[] key2...
#vulnerable code @Test public void testPartialResults() throws Exception { when(mockBigtableApi.getDataClient()).thenReturn(mockDataClientWrapper); when(mockDataClientWrapper.createBulkRead(isA(String.class))).thenReturn(mockBulkRead); byte[] key1 = randomBytes(8); byte[...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void onClose(Status status, Metadata trailers) { try (Scope scope = TRACER.withSpan(operationSpan)) { callWrapper.resetCall(); rpcTimerContext.close(); // OK if (status.isOk()) { if (onOK(trailers)) { finalizeStat...
#vulnerable code @Override public void onClose(Status status, Metadata trailers) { try (Scope scope = TRACER.withSpan(operationSpan)) { synchronized (callLock) { call = NULL_CALL; } rpcTimerContext.close(); // OK if (status.isOk()) { if ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testCBC_UserAgentUsingPlainTextNegotiation() throws Exception{ ServerSocket serverSocket = new ServerSocket(0); final int availablePort = serverSocket.getLocalPort(); serverSocket.close(); //Creates non-ssl server. createServer(available...
#vulnerable code @Test public void testCBC_UserAgentUsingPlainTextNegotiation() throws Exception{ ServerSocket serverSocket = new ServerSocket(0); final int availablePort = serverSocket.getLocalPort(); serverSocket.close(); //Creates non-ssl server. createServer(ava...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private Result[] batch(final List<? extends org.apache.hadoop.hbase.client.Row> actions) throws Exception { return createExecutor().batch(actions); }
#vulnerable code private Result[] batch(final List<? extends org.apache.hadoop.hbase.client.Row> actions) throws Exception { return createExecutor(options).batch(actions); } #location 3 #vulnerability type RESOURCE_LEAK
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void onClose(Status status, Metadata trailers) { synchronized (callLock) { call = null; } rpcTimerContext.close(); // OK if (status.isOk()) { if (onOK(trailers)) { operationTimerContext.close(); } } else { ...
#vulnerable code @Override public void onClose(Status status, Metadata trailers) { synchronized (callLock) { call = null; } rpcTimerContext.close(); Status.Code code = status.getCode(); // OK if (code == Status.Code.OK) { if (onOK()) { opera...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testRetyableMutateRow() throws Exception { final MutateRowRequest request = MutateRowRequest.getDefaultInstance(); when(mockFuture.get()).thenReturn(Empty.getDefaultInstance()); underTest.mutateRow(request); verify(clientCallService, times(1)...
#vulnerable code @Test public void testRetyableMutateRow() throws InterruptedException { final MutateRowRequest request = MutateRowRequest.getDefaultInstance(); final AtomicBoolean done = new AtomicBoolean(false); executor.submit(new Callable<Void>(){ @Override p...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testGetCallback() throws Exception { when(mockBulkRead.add(any(Query.class))).thenReturn(mockFuture); byte[] key = randomBytes(8); FlatRow response = FlatRow.newBuilder().withRowKey(ByteString.copyFrom(key)).build(); setFuture(ImmutableList.o...
#vulnerable code @Test public void testGetCallback() throws Exception { when(mockBulkRead.add(any(Query.class))).thenReturn(mockFuture); byte[] key = randomBytes(8); FlatRow response = FlatRow.newBuilder().withRowKey(ByteString.copyFrom(key)).build(); setFuture(Immutable...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testRefreshAfterStale() throws Exception { underTest = new RefreshingOAuth2CredentialsInterceptor(executorService, credentials); final AccessToken staleToken = new AccessToken("stale", new Date(HeaderCacheElement.TOKEN_STALENESS_MS + 1)); Access...
#vulnerable code @Test public void testRefreshAfterStale() throws Exception { underTest = new RefreshingOAuth2CredentialsInterceptor(executorService, credentials); underTest.rateLimiter.setRate(100000); final AccessToken staleToken = new AccessToken("stale", new Date(Header...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override protected boolean onOK(Metadata trailers) { ProcessingStatus status = requestManager.onOK(); if (status == ProcessingStatus.INVALID) { // Set an exception. onError(INVALID_RESPONSE, trailers); return true; } // There was a problem...
#vulnerable code @Override protected boolean onOK(Metadata trailers) { ProcessingStatus status = requestManager.onOK(); if (status == ProcessingStatus.INVALID) { // Set an exception. onError(INVALID_RESPONSE, trailers); return true; } // There was a p...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testRefreshAfterFailure() throws Exception { underTest = new RefreshingOAuth2CredentialsInterceptor(executorService, credentials); final AccessToken accessToken = new AccessToken("hi", new Date(HeaderCacheElement.TOKEN_STALENESS_MS + 1)); //noi...
#vulnerable code @Test public void testRefreshAfterFailure() throws Exception { underTest = new RefreshingOAuth2CredentialsInterceptor(executorService, credentials); underTest.rateLimiter.setRate(100000); final AccessToken accessToken = new AccessToken("hi", new Date(Header...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test /* * Test that checks that concurrent requests to RefreshingOAuth2CredentialsInterceptor refresh * logic doesn't cause hanging behavior. Specifically, when an Expired condition occurs it * triggers a call to syncRefresh() which potentially waits for refresh th...
#vulnerable code @Test /* * Test that checks that concurrent requests to RefreshingOAuth2CredentialsInterceptor refresh * logic doesn't cause hanging behavior. Specifically, when an Expired condition occurs it * triggers a call to syncRefresh() which potentially waits for refr...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public String authority() { return authority; }
#vulnerable code @Override public String authority() { return delegate.authority(); } #location 3 #vulnerability type THREAD_SAFETY_VIOLATION
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void onClose(Status status, Metadata trailers) { try (NonThrowingCloseable s = TRACER.withSpan(operationSpan)) { synchronized (callLock) { call = null; } rpcTimerContext.close(); // OK if (status.isOk()) { if ...
#vulnerable code @Override public void onClose(Status status, Metadata trailers) { synchronized (callLock) { call = null; } rpcTimerContext.close(); // OK if (status.isOk()) { if (onOK(trailers)) { operationTimerContext.close(); } } els...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void awaitCompletion() throws InterruptedException { boolean performedWarning = false; lock.lock(); try { while (!isFlushed()) { flushedCondition.await(finishWaitMillis, TimeUnit.MILLISECONDS); long now = clock.nanoTime(); if (...
#vulnerable code public void awaitCompletion() throws InterruptedException { boolean performedWarning = false; lock.lock(); try { while (!isFlushed()) { flushedCondition.await(finishWaitMillis, TimeUnit.MILLISECONDS); long now = clock.nanoTime(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testRetyableMutateRow() throws Exception { final MutateRowRequest request = MutateRowRequest.getDefaultInstance(); when(mockFuture.get()).thenReturn(Empty.getDefaultInstance()); underTest.mutateRow(request); verify(clientCallService, times(1)...
#vulnerable code @Test public void testRetyableMutateRow() throws InterruptedException { final MutateRowRequest request = MutateRowRequest.getDefaultInstance(); final AtomicBoolean done = new AtomicBoolean(false); executor.submit(new Callable<Void>(){ @Override p...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected void cancel(final String message) { callWrapper.cancel(message, null); }
#vulnerable code protected void cancel(final String message) { call.cancel(message, null); } #location 2 #vulnerability type THREAD_SAFETY_VIOLATION
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code Future<HeaderCacheElement> asyncRefresh() { LOG.trace("asyncRefresh"); synchronized (lock) { try { if (futureToken != null) { return futureToken; } if (headerCache.getCacheState() == CacheState.Good) { return Futures.im...
#vulnerable code HeaderCacheElement syncRefresh() { try (Closeable ss = Tracing.getTracer().spanBuilder("CredentialsRefresh").startScopedSpan()) { return asyncRefresh().get(TIMEOUT_SECONDS, TimeUnit.SECONDS); } catch (InterruptedException e) { LOG.warn("Interrupted whi...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static Credentials getCredentials(CredentialOptions options) throws IOException, GeneralSecurityException { return patchCredentials(getCredentialsInner(options)); }
#vulnerable code public static Credentials getCredentials(CredentialOptions options) throws IOException, GeneralSecurityException { switch (options.getCredentialType()) { case DefaultCredentials: return getApplicationDefaultCredential(); case P12: P12...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected void run() { try (Scope scope = TRACER.withSpan(operationSpan)) { rpcTimerContext = rpc.getRpcMetrics().timeRpc(); operationSpan.addAnnotation(Annotation.fromDescriptionAndAttributes("rpcStart", ImmutableMap.of("attempt", AttributeValue.longAtt...
#vulnerable code protected void run() { try (Scope scope = TRACER.withSpan(operationSpan)) { rpcTimerContext = rpc.getRpcMetrics().timeRpc(); operationSpan.addAnnotation(Annotation.fromDescriptionAndAttributes("rpcStart", ImmutableMap.of("attempt", AttributeValue.l...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code Future<HeaderCacheElement> asyncRefresh() { LOG.trace("asyncRefresh"); synchronized (lock) { try { if (futureToken != null) { return futureToken; } if (headerCache.getCacheState() == CacheState.Good) { return Futures.im...
#vulnerable code HeaderCacheElement syncRefresh() { try (Closeable ss = Tracing.getTracer().spanBuilder("CredentialsRefresh").startScopedSpan()) { return asyncRefresh().get(TIMEOUT_SECONDS, TimeUnit.SECONDS); } catch (InterruptedException e) { LOG.warn("Interrupted whi...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test /* * Test that checks that concurrent requests to RefreshingOAuth2CredentialsInterceptor refresh * logic doesn't cause hanging behavior. Specifically, when an Expired condition occurs it * triggers a call to syncRefresh() which potentially waits for refresh th...
#vulnerable code @Test /* * Test that checks that concurrent requests to RefreshingOAuth2CredentialsInterceptor refresh * logic doesn't cause hanging behavior. Specifically, when an Expired condition occurs it * triggers a call to syncRefresh() which potentially waits for refr...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @SuppressWarnings("unchecked") @Override public void run() { try { // restart the clock. synchronized (callLock) { super.run(); // pre-fetch one more result, for performance reasons. adapter.request(1); if (rowObserver instanc...
#vulnerable code @SuppressWarnings("unchecked") @Override public void run() { try { // restart the clock. this.rowMerger = new RowMerger(rowObserver); adapter = new CallToStreamObserverAdapter(); synchronized (callLock) { super.run(); // pre...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public IBigtableDataClient getClientWrapper() { if (options.useGCJClient()) { return dataGCJClient; } else { return new BigtableDataClientWrapper(dataClient, getDataRequestContext()); } }
#vulnerable code public IBigtableDataClient getClientWrapper() { if (options.useGCJClient()) { if (this.dataGCJClient == null) { synchronized (BigtableSession.this) { try { if (dataGCJClient == null) { BigtableDataSettings dataSettings...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void onClose(Status status, Metadata trailers) { try (NonThrowingCloseable s = TRACER.withSpan(operationSpan)) { synchronized (callLock) { call = null; } rpcTimerContext.close(); // OK if (status.isOk()) { if ...
#vulnerable code @Override public void onClose(Status status, Metadata trailers) { synchronized (callLock) { call = null; } rpcTimerContext.close(); // OK if (status.isOk()) { if (onOK(trailers)) { operationTimerContext.close(); } } els...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testRefreshAfterFailure() throws Exception { underTest = new RefreshingOAuth2CredentialsInterceptor(executorService, credentials); final AccessToken accessToken = new AccessToken("hi", new Date(HeaderCacheElement.TOKEN_STALENESS_MS + 1)); //noi...
#vulnerable code @Test public void testRefreshAfterFailure() throws Exception { underTest = new RefreshingOAuth2CredentialsInterceptor(executorService, credentials); underTest.rateLimiter.setRate(100000); final AccessToken accessToken = new AccessToken("hi", new Date(Header...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test /* * Test that checks that concurrent requests to RefreshingOAuth2CredentialsInterceptor refresh * logic doesn't cause hanging behavior. Specifically, when an Expired condition occurs it * triggers a call to syncRefresh() which potentially waits for refresh th...
#vulnerable code @Test /* * Test that checks that concurrent requests to RefreshingOAuth2CredentialsInterceptor refresh * logic doesn't cause hanging behavior. Specifically, when an Expired condition occurs it * triggers a call to syncRefresh() which potentially waits for refr...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private Boolean run() throws IOException { try { if (this.role.equals(XLearningConstants.WORKER)) { prepareInputFiles(); } if (this.conf.getBoolean(XLearningConfiguration.XLEARNING_CONTAINER_AUTO_CREATE_OUTPUT_DIR, XLearningConfiguration.DEFAULT_XL...
#vulnerable code private Boolean run() throws IOException { try { if (this.role.equals(XLearningConstants.WORKER)) { prepareInputFiles(); } if (this.conf.getBoolean(XLearningConfiguration.XLEARNING_CONTAINER_AUTO_CREATE_OUTPUT_DIR, XLearningConfiguration.DEFA...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private Boolean run() throws IOException { try { if (this.role.equals(XLearningConstants.WORKER)) { prepareInputFiles(); } if (this.conf.getBoolean(XLearningConfiguration.XLEARNING_CONTAINER_AUTO_CREATE_OUTPUT_DIR, XLearningConfiguration.DEFAULT_XL...
#vulnerable code private Boolean run() throws IOException { try { if (this.role.equals(XLearningConstants.WORKER)) { prepareInputFiles(); } if (this.conf.getBoolean(XLearningConfiguration.XLEARNING_CONTAINER_AUTO_CREATE_OUTPUT_DIR, XLearningConfiguration.DEFA...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private Boolean run() throws IOException { try { if (this.role.equals(XLearningConstants.WORKER)) { prepareInputFiles(); } if (this.conf.getBoolean(XLearningConfiguration.XLEARNING_CONTAINER_AUTO_CREATE_OUTPUT_DIR, XLearningConfiguration.DEFAULT_XL...
#vulnerable code private Boolean run() throws IOException { try { if (this.role.equals(XLearningConstants.WORKER)) { prepareInputFiles(); } if (this.conf.getBoolean(XLearningConfiguration.XLEARNING_CONTAINER_AUTO_CREATE_OUTPUT_DIR, XLearningConfiguration.DEFA...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private Boolean run() throws IOException { try { if (this.role.equals(XLearningConstants.WORKER)) { prepareInputFiles(); } if (this.conf.getBoolean(XLearningConfiguration.XLEARNING_CONTAINER_AUTO_CREATE_OUTPUT_DIR, XLearningConfiguration.DEFAULT_XL...
#vulnerable code private Boolean run() throws IOException { try { if (this.role.equals(XLearningConstants.WORKER)) { prepareInputFiles(); } if (this.conf.getBoolean(XLearningConfiguration.XLEARNING_CONTAINER_AUTO_CREATE_OUTPUT_DIR, XLearningConfiguration.DEFA...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private Boolean run() throws IOException { try { if (this.role.equals(XLearningConstants.WORKER)) { prepareInputFiles(); } if (this.conf.getBoolean(XLearningConfiguration.XLEARNING_CONTAINER_AUTO_CREATE_OUTPUT_DIR, XLearningConfiguration.DEFAULT_XL...
#vulnerable code private Boolean run() throws IOException { try { if (this.role.equals(XLearningConstants.WORKER)) { prepareInputFiles(); } if (this.conf.getBoolean(XLearningConfiguration.XLEARNING_CONTAINER_AUTO_CREATE_OUTPUT_DIR, XLearningConfiguration.DEFA...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private Boolean run() throws IOException { try { if (this.role.equals(XLearningConstants.WORKER)) { prepareInputFiles(); } if (this.conf.getBoolean(XLearningConfiguration.XLEARNING_CONTAINER_AUTO_CREATE_OUTPUT_DIR, XLearningConfiguration.DEFAULT_XL...
#vulnerable code private Boolean run() throws IOException { try { if (this.role.equals(XLearningConstants.WORKER)) { prepareInputFiles(); } if (this.conf.getBoolean(XLearningConfiguration.XLEARNING_CONTAINER_AUTO_CREATE_OUTPUT_DIR, XLearningConfiguration.DEFA...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private Boolean run() throws IOException { try { if (this.role.equals(XLearningConstants.WORKER)) { prepareInputFiles(); } if (this.conf.getBoolean(XLearningConfiguration.XLEARNING_CONTAINER_AUTO_CREATE_OUTPUT_DIR, XLearningConfiguration.DEFAULT_XL...
#vulnerable code private Boolean run() throws IOException { try { if (this.role.equals(XLearningConstants.WORKER)) { prepareInputFiles(); } if (this.conf.getBoolean(XLearningConfiguration.XLEARNING_CONTAINER_AUTO_CREATE_OUTPUT_DIR, XLearningConfiguration.DEFA...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private Boolean run() throws IOException { try { if (this.role.equals(XLearningConstants.WORKER)) { prepareInputFiles(); } if (this.conf.getBoolean(XLearningConfiguration.XLEARNING_CONTAINER_AUTO_CREATE_OUTPUT_DIR, XLearningConfiguration.DEFAULT_XL...
#vulnerable code private Boolean run() throws IOException { try { if (this.role.equals(XLearningConstants.WORKER)) { prepareInputFiles(); } if (this.conf.getBoolean(XLearningConfiguration.XLEARNING_CONTAINER_AUTO_CREATE_OUTPUT_DIR, XLearningConfiguration.DEFA...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private Boolean run() throws IOException { try { if (this.role.equals(XLearningConstants.WORKER)) { prepareInputFiles(); } if (this.conf.getBoolean(XLearningConfiguration.XLEARNING_CONTAINER_AUTO_CREATE_OUTPUT_DIR, XLearningConfiguration.DEFAULT_XL...
#vulnerable code private Boolean run() throws IOException { try { if (this.role.equals(XLearningConstants.WORKER)) { prepareInputFiles(); } if (this.conf.getBoolean(XLearningConfiguration.XLEARNING_CONTAINER_AUTO_CREATE_OUTPUT_DIR, XLearningConfiguration.DEFA...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void writeToFile(String message, String path) throws IOException { if(StringUtils.isEmpty(message) || StringUtils.isEmpty(path)){ return ; } PrintWriter out = null; try { out = new PrintWriter(new BufferedWriter(new FileWriter(path, true))); out.print...
#vulnerable code private void writeToFile(String message, String path) throws IOException{ if(StringUtils.isEmpty(message) || StringUtils.isEmpty(path)){ return ; } RandomAccessFile rf = new RandomAccessFile(path, "rw"); rf.seek(rf.length()); rf.write(message.getBytes()); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private static synchronized void main(final String args, final Instrumentation inst) { try { // 传递的args参数分两个部分:agentJar路径和agentArgs // 分别是Agent的JAR包路径和期望传递到服务端的参数 final int index = args.indexOf(";"); final String agentJ...
#vulnerable code private static synchronized void main(final String args, final Instrumentation inst) { try { // // 传递的args参数分两个部分:agentJar路径和agentArgs // // 分别是Agent的JAR包路径和期望传递到服务端的参数 // final int index = args.indexOf(";"); // final...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void write(long gaSessionId, String jobId, boolean isF, String message) { if(isF){ message += endMark; } if(StringUtils.isEmpty(message)){ return; } RandomAccessFile rf = null; try { new File(executeResultDir).mkdir(); rf = new RandomAcce...
#vulnerable code private void write(long gaSessionId, String jobId, boolean isF, String message) { if(isF){ message += endMark; } if(StringUtils.isEmpty(message)){ return; } RandomAccessFile rf; try { new File(executeResultDir).mkdir(); rf = new RandomAcces...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static Configure toConfigure(String toString) { final Configure configure = new Configure(); final String[] pvs = split(toString, ";"); for (String pv : pvs) { try { final String[] stringSplitArray = split(pv, "="); ...
#vulnerable code public static Configure toConfigure(String toString) { final Configure configure = new Configure(); final String[] pvs = split(toString, ";"); for (String pv : pvs) { try { final String[] stringSplitArray = split(pv, "...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public byte[] transform( ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException { // 这里要再次过滤一次,为啥?因...
#vulnerable code public byte[] transform( ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException { // 这里要再次过滤一...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public String draw() { return filterEmptyLine(tableView.draw()); }
#vulnerable code @Override public String draw() { String content = tableView.draw(); StringBuilder sb = new StringBuilder(); // 清理多余的空格 Scanner scanner = new Scanner(content); while (scanner.hasNextLine()) { String line = scanner.n...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public byte[] transform( ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException { // 这里要再次过滤一次,为啥?因...
#vulnerable code public byte[] transform( ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException { // 这里要再次过滤一...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public byte[] transform( final ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException { // 这里要再次过滤一...
#vulnerable code public byte[] transform( final ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException { // 这里...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void read(String jobId, int pos, RespResult respResult) { int newPos = pos; final StringBuilder sb = new StringBuilder(); RandomAccessFile rf = null; try { rf = new RandomAccessFile(getExecuteFilePath(jobId), "r"); rf.seek(pos); byte[] buffer = new byte[...
#vulnerable code private void read(String jobId, int pos, RespResult respResult) { RandomAccessFile rf; StringBuilder sb = new StringBuilder(); int newPos = pos; try { rf = new RandomAccessFile(getExecuteFilePath(jobId), "r"); rf.seek(pos); byte[] buffer = new byte[10000];...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static void main(String[] args) throws Exception { if (args.length != 3) { printUsage(); return; } File manifestXml = new File(args[0]); String moduleName = args[1]; File baseDir = new File(args[2]); if (!manifestXml.exists()) { ...
#vulnerable code public static void main(String[] args) throws Exception { if (args.length != 3) { printUsage(); return; } File manifestXml = new File(args[0]); String moduleName = args[1]; File baseDir = new File(args[2]); if (!manifestXml.exists()) ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void validate() { Map<String, Binding<?>> allBindings = linkEverything(); new ProblemDetector().detectProblems(allBindings.values()); }
#vulnerable code public void validate() { Map<String, Binding<?>> allBindings; synchronized (linker) { linkStaticInjections(); linkEntryPoints(); allBindings = linker.linkAll(); } new ProblemDetector().detectProblems(allBindings.values()); } ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static String get(Type type, Annotation[] annotations, Object subject) { return get(type, extractQualifier(annotations, subject)); }
#vulnerable code public static String get(Type type, Annotation[] annotations, Object subject) { Annotation qualifier = null; for (Annotation a : annotations) { if (!IS_QUALIFIER_ANNOTATION.get(a.annotationType())) { continue; } if (qualifier != null) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public ObjectGraph plus(Object... modules) { linkEverything(); return makeGraph(this, plugin, modules); }
#vulnerable code public ObjectGraph plus(Object... modules) { linker.linkAll(); return makeGraph(this, plugin, modules); } #location 2 #vulnerability type THREAD_SAFETY_VIOLATION
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static void main(String[] args) throws Exception { if (args.length != 3) { printUsage(); return; } File manifestXml = new File(args[0]); String moduleName = args[1]; File baseDir = new File(args[2]); if (!manifestXml.exists()) { ...
#vulnerable code public static void main(String[] args) throws Exception { if (args.length != 3) { printUsage(); return; } File manifestXml = new File(args[0]); String moduleName = args[1]; File baseDir = new File(args[2]); if (!manifestXml.exists()) ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public boolean lock(long seckillId) { try { if (threadLock.get() == null) { Map<Long, InterProcessMutex> map = new HashMap(); map.put(seckillId,new InterProcessMutex(client,ROOT_LOCK_PATH+"/"+String.valueOf(seckillId))); ...
#vulnerable code public boolean lock(long seckillId) { try { if (lockMap.get(seckillId) == null) { lockMap.put(seckillId, new InterProcessMutex(client, ROOT_LOCK_PATH+"/"+String.valueOf(seckillId))); } lockMap.get(seckillId).ac...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public boolean lock(long seckillId) { try { Map<Long, InterProcessMutex> map; String rootLockPath = "/goodskill"; Map<Long, InterProcessMutex> processMutexMap = threadLock.get(); if (processMutexMap.get(seckillId) == nul...
#vulnerable code public boolean lock(long seckillId) { try { Map<Long, InterProcessMutex> map; String rootLockPath = "/goodskill"; if (threadLock.get() == null) { map = new ConcurrentHashMap(); map.put(seckillId...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private String uploadGoodsPhoto(CommonsMultipartFile file) throws IOException { final String s = "/Users/heng/java学习/"; String path = s + file.getOriginalFilename(); FileOutputStream fos = null; InputStream is = null; try { ...
#vulnerable code private String uploadGoodsPhoto(CommonsMultipartFile file) { final String s = "/Users/heng/java学习/"; String path = s + file.getOriginalFilename(); try { String filePath = s; File file_tmp = new File(filePath); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static void main(String[] args) { SpringApplication.run(GoodsKillRpcServiceApplication.class); }
#vulnerable code public static void main(String[] args) { log.info(">>>>> goodsKill-rpc-service 正在启动 <<<<<"); AbstractApplicationContext context= new ClassPathXmlApplicationContext( "classpath*:META-INF/spring/spring-*.xml"); // 程序退出前优雅关闭JVM ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public boolean lock(long seckillId) { try { Map<Long, InterProcessMutex> map; String rootLockPath = "/goodskill"; Map<Long, InterProcessMutex> processMutexMap = threadLock.get(); if (processMutexMap.get(seckillId) == nul...
#vulnerable code public boolean lock(long seckillId) { try { Map<Long, InterProcessMutex> map; String rootLockPath = "/goodskill"; if (threadLock.get() == null) { map = new ConcurrentHashMap(); map.put(seckillId...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test(expected = NullPointerException.class) public void testCreateNull() { new TemplateList(null,(String[]) null); }
#vulnerable code @Test(expected = NullPointerException.class) public void testCreateNull() { new PatternList((String[]) null); } #location 3 #vulnerability type NULL_DEREFERENCE
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void atExpr(Expr expr) throws CompileError { // array access, member access, // (unary) +, (unary) -, ++, --, !, ~ int token = expr.getOperator(); ASTree oprand = expr.oprand1(); if (token == '.') { String member = (...
#vulnerable code public void atExpr(Expr expr) throws CompileError { // array access, member access, // (unary) +, (unary) -, ++, --, !, ~ int token = expr.getOperator(); ASTree oprand = expr.oprand1(); if (token == '.') { String memb...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public InputStream openClassfile(String classname) { try { URLConnection con = openClassfile0(classname); if (con != null) return con.getInputStream(); } catch (IOException e) {} return null; // no...
#vulnerable code public InputStream openClassfile(String classname) { try { if (packageName == null || classname.startsWith(packageName)) { String jarname = directory + classname.replace('.', '/') + ".class"; URLCon...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void setSuperclass(String superclass) throws CannotCompileException { if (superclass == null) superclass = "java.lang.Object"; try { superClass = constPool.addClassInfo(superclass); LinkedList list = meth...
#vulnerable code public void setSuperclass(String superclass) throws CannotCompileException { if (constPool.getClassInfo(superClass).equals("java.lang.Object")) { if (superclass != null) try { superClass = constPool.add...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void atExpr(Expr expr) throws CompileError { // array access, member access, // (unary) +, (unary) -, ++, --, !, ~ int token = expr.getOperator(); ASTree oprand = expr.oprand1(); if (token == '.') { String member = (...
#vulnerable code public void atExpr(Expr expr) throws CompileError { // array access, member access, // (unary) +, (unary) -, ++, --, !, ~ int token = expr.getOperator(); ASTree oprand = expr.oprand1(); if (token == '.') { String memb...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public CtField lookupField(ASTList className, Symbol fieldName) throws CompileError { return lookupJavaField(Declarator.astToClassName(className, '.'), fieldName); }
#vulnerable code public CtField lookupField(ASTList className, Symbol fieldName) throws CompileError { return lookupField2(Declarator.astToClassName(className, '.'), fieldName); } #location 4 ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void atExpr(Expr expr) throws CompileError { // array access, member access, // (unary) +, (unary) -, ++, --, !, ~ int token = expr.getOperator(); ASTree oprand = expr.oprand1(); if (token == '.') { String member = (...
#vulnerable code public void atExpr(Expr expr) throws CompileError { // array access, member access, // (unary) +, (unary) -, ++, --, !, ~ int token = expr.getOperator(); ASTree oprand = expr.oprand1(); if (token == '.') { String memb...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected CtField fieldAccess(ASTree expr) throws CompileError { if (expr instanceof Member) { Member mem = (Member)expr; String name = mem.get(); try { CtField f = thisClass.getField(name); if (Modif...
#vulnerable code protected CtField fieldAccess(ASTree expr) throws CompileError { if (expr instanceof Member) { String name = ((Member)expr).get(); try { return thisClass.getField(name); } catch (NotFoundException e...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public ClassFile getClassFile2() { ClassFile cfile = classfile; if (cfile != null) return cfile; if (readCounter++ > READ_THRESHOLD) { releaseClassFiles(); readCounter = 0; } if (rawClassfile != nul...
#vulnerable code public ClassFile getClassFile2() { ClassFile cfile = classfile; if (cfile != null) return cfile; if (readCounter++ > READ_THRESHOLD) { getCounter += 2; releaseClassFiles(); readCounter = 0; ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public ClassFile getClassFile2() { if (classfile != null) return classfile; InputStream fin = null; try { fin = classPool.openClassfile(getName()); if (fin == null) throw new NotFoundException(getNam...
#vulnerable code public ClassFile getClassFile2() { if (classfile != null) return classfile; try { byte[] b = classPool.readSource(getName()); DataInputStream dis = new DataInputStream(new ByteArrayInputStream(b)); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void renameClass(String oldName, String newName) { LongVector v = items; int size = numOfItems; classes = new HashMap(classes.size() * 2); for (int i = 1; i < size; ++i) { ConstInfo ci = (ConstInfo)v.elementAt(i); ...
#vulnerable code public void renameClass(String oldName, String newName) { LongVector v = items; int size = numOfItems; for (int i = 1; i < size; ++i) ((ConstInfo)v.elementAt(i)).renameClass(this, oldName, newName); } ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void atBinExpr(BinExpr expr) throws CompileError { int token = expr.getOperator(); int k = CodeGen.lookupBinOp(token); if (k >= 0) { /* arithmetic operators: +, -, *, /, %, |, ^, &, <<, >>, >>> */ if (token =...
#vulnerable code public void atBinExpr(BinExpr expr) throws CompileError { int token = expr.getOperator(); int k = CodeGen.lookupBinOp(token); if (k >= 0) { /* arithmetic operators: +, -, *, /, %, |, ^, &, <<, >>, >>> */ if (t...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void atPlusPlus(int token, ASTree oprand, Expr expr) throws CompileError { boolean isPost = oprand == null; // ++i or i++? if (isPost) oprand = expr.oprand2(); if (oprand instanceof Variable) { Declar...
#vulnerable code private void atPlusPlus(int token, ASTree oprand, Expr expr) throws CompileError { boolean isPost = oprand == null; // ++i or i++? if (isPost) oprand = expr.oprand2(); if (oprand instanceof Variable) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void renameClass(Map classnames) { LongVector v = items; int size = numOfItems; classes = new HashMap(classes.size() * 2); for (int i = 1; i < size; ++i) { ConstInfo ci = (ConstInfo)v.elementAt(i); ci.renameClass(...
#vulnerable code public void renameClass(Map classnames) { LongVector v = items; int size = numOfItems; for (int i = 1; i < size; ++i) ((ConstInfo)v.elementAt(i)).renameClass(this, classnames); } #location 5 ...
Below is the vulnerable code, please generate the patch based on the following information.