input
stringlengths
205
73.3k
output
stringlengths
64
73.2k
instruction
stringclasses
1 value
#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...
#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)...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public String authority() { return delegate.authority(); } #location 3 #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code @Override public String authority() { return authority; }
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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 ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void awaitCompletion() throws InterruptedException { boolean performedWarning = false; lock.lock(); try { while (!isFlushed()) { flushedCondition.await(finishWaitMillis, TimeUnit.MILLISECONDS); long now = clock.nanoTime(); ...
#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 (...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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)...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void setException(Exception exception) { rowObserver.onError(exception); // cleanup any state that was in RowMerger. There may be a partial row in progress which needs // to be reset. rowMerger = new RowMerger(rowObserver); super.set...
#fixed code @Override public void setException(Exception exception) { rowMerger.onError(exception); super.setException(exception); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void cancel(final String message) { call.cancel(message, null); } #location 2 #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code protected void cancel(final String message) { callWrapper.cancel(message, null); }
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#fixed code Future<HeaderCacheElement> asyncRefresh() { LOG.trace("asyncRefresh"); synchronized (lock) { try { if (futureToken != null) { return futureToken; } if (headerCache.getCacheState() == CacheState.Good) { return Futures.im...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#fixed code @Test public void testGetCallback() throws Exception { when(mockBulkRead.add(any(Query.class))).thenReturn(mockFuture); byte[] key = randomBytes(8); Result response = Result.create( ImmutableList.<Cell>of( new RowCell( ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static Credentials getCredentials(CredentialOptions options) throws IOException, GeneralSecurityException { switch (options.getCredentialType()) { case DefaultCredentials: return getApplicationDefaultCredential(); case P12: P12...
#fixed code public static Credentials getCredentials(CredentialOptions options) throws IOException, GeneralSecurityException { return patchCredentials(getCredentialsInner(options)); }
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#fixed code Future<HeaderCacheElement> asyncRefresh() { LOG.trace("asyncRefresh"); synchronized (lock) { try { if (futureToken != null) { return futureToken; } if (headerCache.getCacheState() == CacheState.Good) { return Futures.im...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public IBigtableDataClient getClientWrapper() { if (options.useGCJClient()) { if (this.dataGCJClient == null) { synchronized (BigtableSession.this) { try { if (dataGCJClient == null) { BigtableDataSettings dataSettings...
#fixed code public IBigtableDataClient getClientWrapper() { if (options.useGCJClient()) { return dataGCJClient; } else { return new BigtableDataClientWrapper(dataClient, getDataRequestContext()); } }
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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 ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testSyncRefresh() throws IOException { initialize(HeaderCacheElement.TOKEN_STALENESS_MS + 1); Assert.assertEquals(CacheState.Good, underTest.headerCache.getCacheState()); } #location 4 ...
#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()); }
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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 ...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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()); ...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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, "...
#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, "="); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public byte[] transform( ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException { // 这里要再次过滤一...
#fixed 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.
#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...
#fixed code @Override public String draw() { return filterEmptyLine(tableView.draw()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public byte[] transform( ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException { // 这里要再次过滤一...
#fixed 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.
#vulnerable code public byte[] transform( final ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException { // 这里...
#fixed 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.
#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];...
#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[...
Below is the vulnerable code, please generate the patch based on the following information.
#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()) ...
#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()) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void validate() { Map<String, Binding<?>> allBindings; synchronized (linker) { linkStaticInjections(); linkEntryPoints(); allBindings = linker.linkAll(); } new ProblemDetector().detectProblems(allBindings.values()); } ...
#fixed code public void validate() { Map<String, Binding<?>> allBindings = linkEverything(); new ProblemDetector().detectProblems(allBindings.values()); }
Below is the vulnerable code, please generate the patch based on the following information.
#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) { ...
#fixed code public static String get(Type type, Annotation[] annotations, Object subject) { return get(type, extractQualifier(annotations, subject)); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public ObjectGraph plus(Object... modules) { linker.linkAll(); return makeGraph(this, plugin, modules); } #location 2 #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code public ObjectGraph plus(Object... modules) { linkEverything(); return makeGraph(this, plugin, modules); }
Below is the vulnerable code, please generate the patch based on the following information.
#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()) ...
#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()) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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))); ...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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); ...
#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 { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(String[] args) { log.info(">>>>> goodsKill-rpc-service 正在启动 <<<<<"); AbstractApplicationContext context= new ClassPathXmlApplicationContext( "classpath*:META-INF/spring/spring-*.xml"); // 程序退出前优雅关闭JVM ...
#fixed code public static void main(String[] args) { SpringApplication.run(GoodsKillRpcServiceApplication.class); }
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(String[] args) throws IOException { logger.info(">>>>> goodsKill-rpc-service 正在启动 <<<<<"); ClassPathXmlApplicationContext context= new ClassPathXmlApplicationContext( "classpath*:META-INF/spring/spring-*.xml"); ...
#fixed code public static void main(String[] args) throws IOException { logger.info(">>>>> goodsKill-rpc-service 正在启动 <<<<<"); AbstractApplicationContext context= new ClassPathXmlApplicationContext( "classpath*:META-INF/spring/spring-*.xml"); //程序退...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test(expected = NullPointerException.class) public void testCreateNull() { new PatternList((String[]) null); } #location 3 #vulnerability type NULL_DEREFERENCE
#fixed code @Test(expected = NullPointerException.class) public void testCreateNull() { new TemplateList(null,(String[]) null); }
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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 = (...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected CtField fieldAccess(ASTree expr) throws CompileError { CtField f = null; boolean is_static = false; if (expr instanceof Member) { String name = ((Member)expr).get(); try { f = thisClass.getField(n...
#fixed code protected CtField fieldAccess(ASTree expr) throws CompileError { CtField f = null; boolean is_static = false; if (expr instanceof Member) { String name = ((Member)expr).get(); try { f = thisClass.getField(name); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public InputStream openClassfile(String classname) { try { if (packageName == null || classname.startsWith(packageName)) { String jarname = directory + classname.replace('.', '/') + ".class"; URLCon...
#fixed code public InputStream openClassfile(String classname) { try { URLConnection con = openClassfile0(classname); if (con != null) return con.getInputStream(); } catch (IOException e) {} return null; // no...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void setSuperclass(String superclass) throws CannotCompileException { if (constPool.getClassInfo(superClass).equals("java.lang.Object")) { if (superclass != null) try { superClass = constPool.add...
#fixed code public void setSuperclass(String superclass) throws CannotCompileException { if (superclass == null) superclass = "java.lang.Object"; try { superClass = constPool.addClassInfo(superclass); LinkedList list = meth...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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 = (...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public CtField lookupField(ASTList className, Symbol fieldName) throws CompileError { return lookupField2(Declarator.astToClassName(className, '.'), fieldName); } #location 4 ...
#fixed code public CtField lookupField(ASTList className, Symbol fieldName) throws CompileError { return lookupJavaField(Declarator.astToClassName(className, '.'), fieldName); }
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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 = (...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public ClassFile getClassFile2() { ClassFile cfile = classfile; if (cfile != null) return cfile; if (readCounter++ > READ_THRESHOLD) { getCounter += 2; releaseClassFiles(); readCounter = 0; ...
#fixed code public ClassFile getClassFile2() { ClassFile cfile = classfile; if (cfile != null) return cfile; if (readCounter++ > READ_THRESHOLD) { releaseClassFiles(); readCounter = 0; } if (rawClassfile != nul...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public ClassFile getClassFile2() { if (classfile != null) return classfile; try { byte[] b = classPool.readSource(getName()); DataInputStream dis = new DataInputStream(new ByteArrayInputStream(b)); ...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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); } ...
#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); ...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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 =...
Below is the vulnerable code, please generate the patch based on the following information.
#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) { ...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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 ...
#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(...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Class toClass() throws NotFoundException, IOException, CannotCompileException { return getClassPool().toClass(this); } #location 4 #vulnerability type NULL_DEREFERENCE
#fixed code public Class toClass() throws CannotCompileException { return toClass(Thread.currentThread().getContextClassLoader()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected CtField fieldAccess(ASTree expr) throws CompileError { CtField f = null; boolean is_static = false; if (expr instanceof Member) { String name = ((Member)expr).get(); try { f = thisClass.getField(n...
#fixed code protected CtField fieldAccess(ASTree expr) throws CompileError { CtField f = null; boolean is_static = false; if (expr instanceof Member) { String name = ((Member)expr).get(); try { f = thisClass.getField(name); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private String getUrlContents(String urlString) throws Exception { System.setProperty ("jsse.enableSNIExtension", "false"); URL url = new URL(urlString); BufferedReader in = new BufferedReader( new InputStreamReader(url.openStream())); String inputL...
#fixed code private String getUrlContents(String urlString) throws Exception { System.setProperty ("jsse.enableSNIExtension", "false"); URL url = new URL(urlString); URLConnection urlc = url.openConnection(); urlc.setRequestProperty("Accept", "application/json, */*"); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testParsingErrorPositionLargeInput() throws IOException { // 2048 is the buffer size, this will allow us to test position // information for large input that needs to be buffered char[] in = new char[2048 + 7]; in[0] = '['; for (int i = 1; i < ...
#fixed code @Test public void testParsingErrorPositionLargeInput() throws IOException { // 2048 is the buffer size, this will allow us to test position // information for large input that needs to be buffered char[] in = new char[2048 + 7]; in[0] = '['; for (int i = 1; i < 2046; ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testMultipleCallsTonextObjectMetadata() throws IOException { String src = "{\"@class\" : \"theclass\"" + ", \"@author\":\"me\"" + ", \"@comment\":\"no comment\"}"; JsonReader reader = new JsonReader(new StringReader(src)); assertEquals("...
#fixed code @Test public void testMultipleCallsTonextObjectMetadata() throws IOException { String src = "{\"@class\" : \"theclass\"" + ", \"@author\":\"me\"" + ", \"@comment\":\"no comment\"}"; JsonReader reader = new JsonReader(new StringReader(src)); assertEquals("thecla...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public <T> String serialize(T o, GenericType<T> type) throws TransformationException, IOException { JsonWriter writer = new JsonWriter(new StringWriter(), skipNull, htmlSafe); if (o == null) nullConverter.serialize(null, writer, null); else serialize(o, type...
#fixed code public <T> String serialize(T o, GenericType<T> type) throws TransformationException, IOException { StringWriter sw = new StringWriter(); ObjectWriter writer = createWriter(sw); if (o == null) nullConverter.serialize(null, writer, null); else serialize(o, type.g...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testIllegalReadObjectInstedOfArray() throws IOException { String src = "[1,2]"; JsonReader reader = new JsonReader(new StringReader(src)); try { reader.beginObject(); fail(); } catch (IllegalStateException ise) {} } ...
#fixed code @Test public void testIllegalReadObjectInstedOfArray() throws IOException { String src = "[1,2]"; JsonReader reader = new JsonReader(new StringReader(src)); try { reader.beginObject(); fail(); } catch (IllegalStateException ise) {} reader.close(); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testReadMalformedJson() throws IOException { String src = ""; JsonReader reader = new JsonReader(new StringReader(src), strictDoubleParse, readMetadata); try { reader.beginObject(); fail(); } catch (IllegalStateException ise) { } reader...
#fixed code @Test public void testReadMalformedJson() throws IOException { String src = ""; JsonReader reader = new JsonReader(new StringReader(src), strictDoubleParse, readMetadata); try { reader.beginObject(); fail(); } catch (JsonStreamException ise) { } reader.close()...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public <T> String serialize(T o) throws TransformationException, IOException { JsonWriter writer = new JsonWriter(new StringWriter(), skipNull, htmlSafe); if (o == null) nullConverter.serialize(null, writer, null); else serialize(o, o.getClass(), writer, new Co...
#fixed code public <T> String serialize(T o) throws TransformationException, IOException { StringWriter sw = new StringWriter(); ObjectWriter writer = createWriter(sw); if (o == null) nullConverter.serialize(null, writer, null); else serialize(o, o.getClass(), writer, new Cont...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testIllegalReadObjectInstedOfArray() throws IOException { String src = "[1,2]"; JsonReader reader = new JsonReader(new StringReader(src), strictDoubleParse, readMetadata); try { reader.beginObject(); fail(); } catch (IllegalStateException i...
#fixed code @Test public void testIllegalReadObjectInstedOfArray() throws IOException { String src = "[1,2]"; JsonReader reader = new JsonReader(new StringReader(src), strictDoubleParse, readMetadata); try { reader.beginObject(); fail(); } catch (JsonStreamException ise) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public boolean valueAsBoolean() throws IOException { if (BOOLEAN == valueType) { return _booleanValue; } if (STRING == valueType) return "".equals(_stringValue) ? null : Boolean.valueOf(_stringValue); if (NULL == valueType) return false; throw new IllegalSt...
#fixed code public boolean valueAsBoolean() throws IOException { if (BOOLEAN == valueType) { return _booleanValue; } if (STRING == valueType) return Boolean.parseBoolean(_stringValue); if (NULL == valueType) return false; throw new IllegalStateException("Readen value is not ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private final void newMisplacedTokenException(int cursor) { if (_buflen < 0) throw new IllegalStateException( "Incomplete data or malformed json : encoutered end of stream."); if (cursor < 0) cursor = 0; int pos = (_position - valueAsString().length() - _buf...
#fixed code private final void newMisplacedTokenException(int cursor) { if (_buflen < 0) throw new IllegalStateException( "Incomplete data or malformed json : encoutered end of stream."); if (cursor < 0) cursor = 0; int pos = _position - (_buflen - cursor); if (pos < 0) pos...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public <T> String serialize(T o, Class<? extends BeanView<?>>... withViews) throws TransformationException, IOException { JsonWriter writer = new JsonWriter(new StringWriter(), skipNull, htmlSafe); if (o == null) nullConverter.serialize(null, writer, null); els...
#fixed code public <T> String serialize(T o, Class<? extends BeanView<?>>... withViews) throws TransformationException, IOException { StringWriter sw = new StringWriter(); ObjectWriter writer = createWriter(sw); if (o == null) nullConverter.serialize(null, writer, null); else ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private final void newWrongTokenException(String awaited, int cursor) { // otherwise it fails when an error occurs on first character if (cursor < 0) cursor = 0; int pos = (_position - valueAsString().length() - _buflen + cursor); if (pos < 0) pos = 0; if (_bufl...
#fixed code private final void newWrongTokenException(String awaited, int cursor) { // otherwise it fails when an error occurs on first character if (cursor < 0) cursor = 0; int pos = _position - (_buflen - cursor); if (pos < 0) pos = 0; if (_buflen < 0) throw new IllegalState...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testIncompleteSource() throws IOException { String src = "[1,"; JsonReader reader = new JsonReader(new StringReader(src)); try { reader.beginArray(); reader.next(); reader.next(); fail(); } catch (IOException ioe) {} } ...
#fixed code @Test public void testIncompleteSource() throws IOException { String src = "[1,"; JsonReader reader = new JsonReader(new StringReader(src)); try { reader.beginArray(); reader.next(); reader.next(); fail(); } catch (IOException ioe) {} reader.close(); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void run(Bootstrap bootstrap, Namespace args) { // read and initialize arguments: GraphHopperConfig graphHopperConfiguration = new GraphHopperConfig(); graphHopperConfiguration.putObject("graph.location", "graph-cache"); ...
#fixed code @Override public void run(Bootstrap bootstrap, Namespace args) { // read and initialize arguments: GraphHopperConfig graphHopperConfiguration = new GraphHopperConfig(); graphHopperConfiguration.setProfiles(Collections.singletonList(new ProfileConfi...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void run(Bootstrap bootstrap, Namespace args) { // read and initialize arguments: CmdArgs graphHopperConfiguration = new CmdArgs(); graphHopperConfiguration.put("graph.location", "graph-cache"); seed = args.getLong("s...
#fixed code @Override public void run(Bootstrap bootstrap, Namespace args) { // read and initialize arguments: CmdArgs graphHopperConfiguration = new CmdArgs(); graphHopperConfiguration.put("graph.location", "graph-cache"); seed = args.getLong("seed");...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void run(Bootstrap bootstrap, Namespace args) { // read and initialize arguments: GraphHopperConfig graphHopperConfiguration = new GraphHopperConfig(); graphHopperConfiguration.putObject("graph.location", "graph-cache"); ...
#fixed code @Override public void run(Bootstrap bootstrap, Namespace args) { // read and initialize arguments: GraphHopperConfig graphHopperConfiguration = new GraphHopperConfig(); graphHopperConfiguration.setProfiles(Collections.singletonList(new ProfileConfi...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void run(Bootstrap bootstrap, Namespace args) { // read and initialize arguments: CmdArgs graphHopperConfiguration = new CmdArgs(); graphHopperConfiguration.put("graph.location", "graph-cache"); seed = args.getLong("s...
#fixed code @Override public void run(Bootstrap bootstrap, Namespace args) { // read and initialize arguments: CmdArgs graphHopperConfiguration = new CmdArgs(); graphHopperConfiguration.put("graph.location", "graph-cache"); seed = args.getLong("seed");...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testEvaluate() { CosineSimilarityUDF cosine = new CosineSimilarityUDF(); { List<String> ftvec1 = Arrays.asList("bbb:1.4", "aaa:0.9", "ccc"); Assert.assertEquals(1.f, cosine.evaluate(ftvec1, ftvec1).get(), 0....
#fixed code @Test public void testEvaluate() throws IOException { { List<String> ftvec1 = Arrays.asList("bbb:1.4", "aaa:0.9", "ccc"); Assert.assertEquals(1.f, CosineSimilarityUDF.cosineSimilarity(ftvec1, ftvec1), 0.0); } Assert.assertE...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private static int evalPredict(DecisionTree tree, double[] x) throws HiveException, IOException { String script = tree.predictCodegen(); System.out.println(script); TreePredictTrustedUDF udf = new TreePredictTrustedUDF(); udf.initialize(n...
#fixed code private static int evalPredict(DecisionTree tree, double[] x) throws HiveException, IOException { String script = tree.predictCodegen(); System.out.println(script); TreePredictByJavascriptUDF udf = new TreePredictByJavascriptUDF(); udf.initiali...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private static long loadPredictionModel(PredictionModel model, File file, PrimitiveObjectInspector featureOI, WritableFloatObjectInspector weightOI, WritableFloatObjectInspector covarOI) throws IOException, SerDeException { long count = 0L; i...
#fixed code private static long loadPredictionModel(PredictionModel model, File file, PrimitiveObjectInspector featureOI, WritableFloatObjectInspector weightOI, WritableFloatObjectInspector covarOI) throws IOException, SerDeException { long count = 0L; if(!fil...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private long loadPredictionModel(Map<Object, PredictionModel> label2model, File file, PrimitiveObjectInspector labelOI, PrimitiveObjectInspector featureOI, WritableFloatObjectInspector weightOI, WritableFloatObjectInspector covarOI) throws IOException, SerDe...
#fixed code private long loadPredictionModel(Map<Object, PredictionModel> label2model, File file, PrimitiveObjectInspector labelOI, PrimitiveObjectInspector featureOI, WritableFloatObjectInspector weightOI, WritableFloatObjectInspector covarOI) throws IOException, SerDeExcept...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override protected CommandLine processOptions(ObjectInspector[] argOIs) throws UDFArgumentException { CommandLine cl = super.processOptions(argOIs); this.eta0 = Primitives.parseFloat(cl.getOptionValue("eta0"), 0.1f); this.eps = Primitives.pa...
#fixed code @Override protected CommandLine processOptions(ObjectInspector[] argOIs) throws UDFArgumentException { CommandLine cl = super.processOptions(argOIs); if(cl == null) { this.eta0 = 0.1f; this.eps = 1.f; this.scaling = 100f...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private boolean executeOperation(Operation currentOperation) throws VMRuntimeException { if(IP < 0) return false; switch (currentOperation.op) { case GOTO: if(isInt(currentOperation.operand)) IP...
#fixed code private boolean executeOperation(Operation currentOperation) throws VMRuntimeException { if(IP < 0) { return false; } switch (currentOperation.op) { case GOTO: { if(isInt(currentOperation.operand)) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Nonnull public byte[] predictSerCodegen(boolean compress) throws HiveException { final Attribute[] attrs = _attributes; assert (attrs != null); FastMultiByteArrayOutputStream bos = new FastMultiByteArrayOutputStream(); OutputStream ...
#fixed code @Nonnull public byte[] predictSerCodegen(boolean compress) throws HiveException { try { if (compress) { return ObjectUtils.toCompressedBytes(_root); } else { return ObjectUtils.toBytes(_root); } ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Nonnull public byte[] predictSerCodegen(boolean compress) throws HiveException { final Attribute[] attrs = _attributes; assert (attrs != null); FastMultiByteArrayOutputStream bos = new FastMultiByteArrayOutputStream(); OutputStream ...
#fixed code @Nonnull public byte[] predictSerCodegen(boolean compress) throws HiveException { try { if (compress) { return ObjectUtils.toCompressedBytes(_root); } else { return ObjectUtils.toBytes(_root); } ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static <T> T readObject(@Nonnull final byte[] obj) throws IOException, ClassNotFoundException { return readObject(new FastByteArrayInputStream(obj)); } #location 3 #vulnerability ty...
#fixed code public static <T> T readObject(@Nonnull final byte[] obj) throws IOException, ClassNotFoundException { return readObject(obj, obj.length); }
Below is the vulnerable code, please generate the patch based on the following information.