input
stringlengths
205
73.3k
output
stringlengths
64
73.2k
instruction
stringclasses
1 value
#vulnerable code public static String getCluster(Configuration jobConf) { String jobtracker = jobConf.get(JOBTRACKER_KEY); if (jobtracker == null) { jobtracker = jobConf.get(RESOURCE_MANAGER_KEY); } // strip any port number int portIdx = jobtracker.indexOf(':'); ...
#fixed code public static String getCluster(Configuration jobConf) { String jobtracker = jobConf.get(JOBTRACKER_KEY); if (jobtracker == null) { jobtracker = jobConf.get(RESOURCE_MANAGER_KEY); } String cluster = null; if (jobtracker != null) { // strip any po...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public int getQSize() { int res = 0; for (int i = 0; i < queues.length; i++) { Queue queue = queues[i]; res+=queue.size(); } for (int i = 0; i < queues.length; i++) { Queue queue = cbQueues[i]; ...
#fixed code public int getQSize() { int res = 0; final Actor actors[] = this.actors; for (int i = 0; i < actors.length; i++) { Actor a = actors[i]; res+=a.__mailbox.size(); res+=a.__cbQueue.size(); } return res; ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public boolean pollQs() { CallEntry poll = pollQueues(cbQueues, queues); // first callback queues if (poll != null) { try { Actor.sender.set(poll.getTargetActor()); Object invoke = null; profile...
#fixed code public boolean pollQs() { CallEntry poll = pollQueues(cbQueues, queues); // first callback queues if (poll != null) { try { Actor.sender.set(poll.getTargetActor()); Object invoke = null; profileCounte...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void rebalance(DispatcherThread dispatcherThread) { int load = dispatcherThread.getLoad(); DispatcherThread minLoadThread = createNewThreadIfPossible(); if ( minLoadThread != null ) { // split dispatch...
#fixed code @Override public void rebalance(DispatcherThread dispatcherThread) { synchronized (balanceLock) { long load = dispatcherThread.getLoadNanos(); DispatcherThread minLoadThread = createNewThreadIfPossible(); if (minLoadThread != nu...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void run() { int emptyCount = 0; boolean isShutDown = false; while( ! isShutDown ) { if ( pollQs() ) { emptyCount = 0; } else { emptyCount++; scheduler.yi...
#fixed code public void run() { int emptyCount = 0; boolean isShutDown = false; while( ! isShutDown ) { if ( pollQs() ) { emptyCount = 0; } else { emptyCount++; scheduler.yield(em...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public int getQSize() { int res = 0; for (int i = 0; i < queues.length; i++) { Queue queue = queues[i]; res+=queue.size(); } for (int i = 0; i < queues.length; i++) { Queue queue = cbQueues[i]; ...
#fixed code public int getQSize() { int res = 0; final Actor actors[] = this.actors; for (int i = 0; i < actors.length; i++) { Actor a = actors[i]; res+=a.__mailbox.size(); res+=a.__cbQueue.size(); } return res; ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public boolean pollQs() { CallEntry poll = pollQueues(cbQueues, queues); // first callback queues if (poll != null) { try { Actor.sender.set(poll.getTargetActor()); Object invoke = null; profile...
#fixed code public boolean pollQs() { CallEntry poll = pollQueues(cbQueues, queues); // first callback queues if (poll != null) { try { Actor.sender.set(poll.getTargetActor()); Object invoke = null; profileCounte...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public int getLoad() { int res = 0; for (int i = 0; i < queues.length; i++) { MpscConcurrentQueue queue = (MpscConcurrentQueue) queues[i]; int load = queue.size() * 100 / queue.getCapacity(); if ( load > res ) ...
#fixed code public int getLoad() { int res = 0; final Actor actors[] = this.actors; for (int i = 0; i < actors.length; i++) { MpscConcurrentQueue queue = (MpscConcurrentQueue) actors[i].__mailbox; int load = queue.size() * 100 / queue.getCa...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public boolean isEmpty() { for (int i = 0; i < queues.length; i++) { Queue queue = queues[i]; if ( ! queue.isEmpty() ) return false; } for (int i = 0; i < cbQueues.length; i++) { Queue queue = c...
#fixed code public boolean isEmpty() { for (int i = 0; i < actors.length; i++) { Actor act = actors[i]; if ( ! act.__mailbox.isEmpty() || ! act.__cbQueue.isEmpty() ) return false; } return true; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void run() { int emptyCount = 0; boolean isShutDown = false; while( ! isShutDown ) { if ( pollQs() ) { emptyCount = 0; } else { emptyCount++; scheduler.yi...
#fixed code public void run() { int emptyCount = 0; int scheduleNewActorCount = 0; boolean isShutDown = false; while( ! isShutDown ) { if ( pollQs() ) { emptyCount = 0; scheduleNewActorCount++; if...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public boolean isEmpty() { for (int i = 0; i < queues.length; i++) { Queue queue = queues[i]; if ( ! queue.isEmpty() ) return false; } for (int i = 0; i < cbQueues.length; i++) { Queue queue = c...
#fixed code public boolean isEmpty() { for (int i = 0; i < actors.length; i++) { Actor act = actors[i]; if ( ! act.__mailbox.isEmpty() || ! act.__cbQueue.isEmpty() ) return false; } return true; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public boolean pollQs() { CallEntry poll = pollQueues(cbQueues, queues); // first callback queues if (poll != null) { try { Actor.sender.set(poll.getTargetActor()); Object invoke = null; profile...
#fixed code public boolean pollQs() { CallEntry poll = pollQueues(actors); // first callback actors if (poll != null) { try { Actor.sender.set(poll.getTargetActor()); Object invoke = null; profileCounter++; ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void run() { int emptyCount = 0; boolean isShutDown = false; while( ! isShutDown ) { if ( pollQs() ) { emptyCount = 0; } else { emptyCount++; scheduler.yi...
#fixed code public void run() { int emptyCount = 0; int scheduleNewActorCount = 0; boolean isShutDown = false; while( ! isShutDown ) { if ( pollQs() ) { emptyCount = 0; scheduleNewActorCount++; if...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public boolean pollQs() { CallEntry poll = pollQueues(cbQueues, queues); // first callback queues if (poll != null) { try { Actor.sender.set(poll.getTargetActor()); Object invoke = null; profile...
#fixed code public boolean pollQs() { CallEntry poll = pollQueues(actors); // first callback actors if (poll != null) { try { Actor.sender.set(poll.getTargetActor()); Object invoke = null; profileCounter++; ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void run() { int emptyCount = 0; boolean isShutDown = false; while( ! isShutDown ) { if ( pollQs() ) { emptyCount = 0; } else { emptyCount++; scheduler.yi...
#fixed code public void run() { int emptyCount = 0; boolean isShutDown = false; while( ! isShutDown ) { if ( pollQs() ) { emptyCount = 0; } else { emptyCount++; scheduler.yield(em...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public Collection<?> getSortableContainerPropertyIds() { if (backingList instanceof SortableLazyList) { // Assume SortableLazyList can sort by any Comparable property } else if (backingList instanceof LazyList) { // ...
#fixed code @Override public Collection<?> getSortableContainerPropertyIds() { if (backingList instanceof SortableLazyList) { // Assume SortableLazyList can sort by any Comparable property } else if (backingList instanceof LazyList) { // When u...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public Property getContainerProperty(Object itemId, Object propertyId) { return getItem(itemId).getItemProperty(propertyId); } #location 3 #vulnerability type NULL_DEREFERENCE
#fixed code @Override public Property getContainerProperty(Object itemId, Object propertyId) { Item i = getItem(itemId); return (i != null) ? i.getItemProperty(propertyId) : null; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void visitIincInsn(int var, int increment) { super.visitIincInsn(var, increment); // Track variable state and name at variable stores. (At variable increases.) LocalVariableScope lvs = getLocalVariableScope(var); instrumentToTrackVariableName(l...
#fixed code @Override public void visitIincInsn(int var, int increment) { super.visitIincInsn(var, increment); // Track variable state at variable increases (e.g. i++). LocalVariableScope lvs = getLocalVariableScope(var); instrumentToTrackVariableState(lvs, lineNumber); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @RequestMapping(value = "/api/processor", method = RequestMethod.POST, headers = "Accept=application/json") ConversationDTO requestProcessor(@RequestParam(value = "runnerLogId", required = false) String runnerLogId, @RequestBody RfRequestDTO rfRequestDTO) { Convers...
#fixed code @RequestMapping(value = "/api/processor", method = RequestMethod.POST, headers = "Accept=application/json") ConversationDTO requestProcessor(@RequestParam(value = "runnerLogId", required = false) String runnerLogId, @RequestBody RfRequestDTO rfRequestDTO) { Conversation ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @RequestMapping(value = "/api/{projectId}/entities/{name}/{uuid}", method = RequestMethod.PUT, headers = "Accept=application/json", consumes = "application/json") public @ResponseBody String updateEntityData(@PathVariable("projectId") String projectId, @PathVari...
#fixed code @RequestMapping(value = "/api/{projectId}/entities/{name}/{uuid}", method = RequestMethod.PUT, headers = "Accept=application/json", consumes = "application/json") public @ResponseBody String updateEntityData(@PathVariable("projectId") String projectId, @PathVariable("...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void rfToSwaggerConverter(String projectId) { Swagger swagger = new SwaggerParser().read("http://petstore.swagger.io/v2/swagger.json"); Project project = projectController.findById(null, projectId); String projectNodeRefId = project.getProjectRef().getId(); ...
#fixed code private void rfToSwaggerConverter(String projectId) { Swagger swagger = new SwaggerParser().read("http://petstore.swagger.io/v2/swagger.json"); Project project = projectController.findById(null, projectId); String projectNodeRefId = project.getProjectRef().getId(); Tre...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private ModbusPdu decodeException(FunctionCode functionCode, ByteBuf buffer) throws DecoderException { int code = buffer.readByte(); ExceptionCode exceptionCode = ExceptionCode .fromCode(code) .orElseThrow(() -> new Decod...
#fixed code private ModbusPdu decodeException(FunctionCode functionCode, ByteBuf buffer) throws DecoderException { int code = buffer.readUnsignedByte(); ExceptionCode exceptionCode = ExceptionCode .fromCode(code) .orElseThrow(() -> new Dec...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public long appendUtf8(long pos, char[] chars, int offset, int length) { if (pos + length > realCapacity()) throw new BufferOverflowException(); long address = this.address + translate(0); Memory memory = this.memory; int i; ...
#fixed code public long appendUtf8(long pos, char[] chars, int offset, int length) { if (pos + length > realCapacity()) throw new BufferOverflowException(); long address = this.address + translate(0); Memory memory = this.memory; if (memory ==...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testName() { NativeBytesStore<Void> nativeStore = NativeBytesStore.nativeStoreWithFixedCapacity(30); Bytes<Void> bytes = nativeStore.bytesForWrite(); long expected = 12345L; int offset = 5; bytes.writeLong(...
#fixed code @Test public void testName() { Bytes<Void> bytes = Bytes.allocateDirect(30); long expected = 12345L; int offset = 5; bytes.writeLong(offset, expected); bytes.writePosition(offset + 8); assertEquals(expected, bytes.readLong...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testName() { NativeBytesStore<Void> nativeStore = NativeBytesStore.nativeStoreWithFixedCapacity(30); Bytes<Void> bytes = nativeStore.bytesForWrite(); long expected = 12345L; int offset = 5; bytes.writeLong(...
#fixed code @Test public void testName() { Bytes<Void> bytes = Bytes.allocateDirect(30); long expected = 12345L; int offset = 5; bytes.writeLong(offset, expected); bytes.writePosition(offset + 8); assertEquals(expected, bytes.readLong...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static BytesStore<Bytes<Void>, Void> copyOf(Bytes bytes) { long remaining = bytes.readRemaining(); NativeBytes<Void> bytes2 = NativeBytes.nativeBytes(remaining); bytes2.write(bytes, 0, remaining); return bytes2; } ...
#fixed code public static BytesStore<Bytes<Void>, Void> copyOf(Bytes bytes) { long remaining = bytes.readRemaining(); NativeBytes<Void> bytes2 = Bytes.allocateElasticDirect(remaining); bytes2.write(bytes, 0, remaining); return bytes2; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Bytes acquireBytesForWrite(long position) throws IOException, IllegalStateException, IllegalArgumentException { MappedBytesStore mbs = acquireByteStore(position); MappedBytes bytes = mbs.bytesForWrite(); bytes.writePosition(pos...
#fixed code public Bytes acquireBytesForWrite(long position) throws IOException, IllegalStateException, IllegalArgumentException { MappedBytesStore mbs = acquireByteStore(position); Bytes bytes = mbs.bytesForWrite(); bytes.writePosition(position); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testName() { NativeBytesStore<Void> nativeStore = NativeBytesStore.nativeStoreWithFixedCapacity(30); Bytes<Void> bytes = nativeStore.bytesForWrite(); long expected = 12345L; int offset = 5; bytes.writeLong(...
#fixed code @Test public void testName() { Bytes<Void> bytes = Bytes.allocateDirect(30); long expected = 12345L; int offset = 5; bytes.writeLong(offset, expected); bytes.writePosition(offset + 8); assertEquals(expected, bytes.readLong...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Bytes acquireBytesForWrite(long position) throws IOException, IllegalStateException, IllegalArgumentException { MappedBytesStore mbs = acquireByteStore(position); Bytes bytes = mbs.bytesForWrite(); bytes.writePosition(position)...
#fixed code public Bytes acquireBytesForWrite(long position) throws IOException, IllegalStateException, IllegalArgumentException { MappedBytesStore mbs = acquireByteStore(position); MappedBytes bytes = mbs.bytesForWrite(); bytes.writePosition(position)...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public long appendUtf8(long pos, char[] chars, int offset, int length) { if (pos + length > realCapacity()) throw new BufferOverflowException(); long address = this.address + translate(0); Memory memory = this.memory; int i; ...
#fixed code public long appendUtf8(long pos, char[] chars, int offset, int length) { if (pos + length > realCapacity()) throw new BufferOverflowException(); long address = this.address + translate(0); Memory memory = this.memory; if (memory ==...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public boolean compareAndSwapValue(long expected, long value) { if (value == LONG_NOT_COMPLETE && binaryLongReferences != null) binaryLongReferences.add(new WeakReference<>(this)); return bytes.compareAndSwapLong(offset, expecte...
#fixed code @Override public boolean compareAndSwapValue(long expected, long value) { BytesStore bytes = this.bytes; return bytes != null && bytes.compareAndSwapLong(offset, expected, value); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void toHexString() { Bytes bytes = NativeBytes.nativeBytes(1020); bytes.append("Hello World"); assertEquals("00000000 48 65 6C 6C 6F 20 57 6F 72 6C 64 Hello Wo rld \n", bytes.toHexString()); bytes.read...
#fixed code @Test public void toHexString() { Bytes bytes = Bytes.allocateElasticDirect(1020); bytes.append("Hello World"); assertEquals("00000000 48 65 6C 6C 6F 20 57 6F 72 6C 64 Hello Wo rld \n", bytes.toHexString()); bytes.readLi...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public int peekVolatileInt() { readCheckOffset(readPosition, 4, true); MappedBytesStore bytesStore = (MappedBytesStore) (BytesStore) this.bytesStore; long address = bytesStore.address + bytesStore.translate(readPosition); Me...
#fixed code @Override public int peekVolatileInt() { if (!bytesStore.inside(readPosition)) { acquireNextByteStore(readPosition); } MappedBytesStore bytesStore = (MappedBytesStore) (BytesStore) this.bytesStore; long address = bytesStore.add...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public int byteCheckSum() throws IORuntimeException { if (readLimit() >= Integer.MAX_VALUE || start() != 0) return super.byteCheckSum(); byte b = 0; NativeBytesStore bytesStore = (NativeBytesStore) bytesStore(); for (int i = (...
#fixed code public int byteCheckSum() throws IORuntimeException { if (readLimit() >= Integer.MAX_VALUE || start() != 0) return super.byteCheckSum(); byte b = 0; NativeBytesStore bytesStore = (NativeBytesStore) bytesStore(); Memory memory = byte...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void toHexString() { Bytes bytes = NativeBytes.nativeBytes(1020); bytes.append("Hello World"); assertEquals("00000000 48 65 6C 6C 6F 20 57 6F 72 6C 64 Hello Wo rld \n", bytes.toHexString()); bytes.read...
#fixed code @Test public void toHexString() { Bytes bytes = Bytes.allocateElasticDirect(1020); bytes.append("Hello World"); assertEquals("00000000 48 65 6C 6C 6F 20 57 6F 72 6C 64 Hello Wo rld \n", bytes.toHexString()); bytes.readLi...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void shouldBeReadOnly() throws Exception { final File tempFile = File.createTempFile("mapped", "bytes"); final RandomAccessFile raf = new RandomAccessFile(tempFile, "rw"); raf.setLength(4096); assertTrue(tempFile.setWrita...
#fixed code @Test public void shouldBeReadOnly() throws Exception { final File tempFile = File.createTempFile("mapped", "bytes"); tempFile.deleteOnExit(); try (RandomAccessFile raf = new RandomAccessFile(tempFile, "rw")) { raf.setLength(4096); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Nullable public MappedBytesStore acquireByteStore(long position) throws IOException { if (closed.get()) throw new IOException("Closed"); int chunk = (int) (position / chunkSize); synchronized (stores) { while (stores....
#fixed code @Nullable public MappedBytesStore acquireByteStore(long position) throws IOException { if (closed.get()) throw new IOException("Closed"); int chunk = (int) (position / chunkSize); synchronized (stores) { while (stores.size()...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testCapacity() { assertEquals(SIZE, bytes.capacity()); assertEquals(10, NativeBytesStore.nativeStoreWithFixedCapacity(10).capacity()); } #location 4 #vulnerability type R...
#fixed code @Test public void testCapacity() { assertEquals(SIZE, bytes.capacity()); assertEquals(10, Bytes.allocateDirect(10).capacity()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public ProtocolProcessor init(IConfig props) { subscriptions = new SubscriptionsStore(); //TODO use a property to select the storage path m_mapStorage = new MapDBPersistentStore(props.getProperty(PERSISTENT_STORE_PROPERTY_NAME, "")); m_m...
#fixed code public ProtocolProcessor init(IConfig props) { subscriptions = new SubscriptionsStore(); m_mapStorage = new MapDBPersistentStore(props); m_mapStorage.initStore(); IMessagesStore messagesStore = m_mapStorage.messagesStore(); ISessionsSt...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void handleConnect(IoSession session, ConnectMessage msg) { LOG.info("handleConnect invoked"); if (msg.getProcotolVersion() != 0x03) { ConnAckMessage badProto = new ConnAckMessage(); badProto.setReturnCode(ConnAckMessage...
#fixed code protected void handleConnect(IoSession session, ConnectMessage msg) { LOG.info("handleConnect invoked"); m_messaging.connect(session, msg); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testPublishWithQoS2() throws Exception { LOG.info("*** testPublishWithQoS2 ***"); MqttConnectOptions options = new MqttConnectOptions(); options.setCleanSession(false); m_client.connect(options); m_client.sub...
#fixed code @Test public void testPublishWithQoS2() throws Exception { LOG.info("*** testPublishWithQoS2 ***"); MqttConnectOptions options = new MqttConnectOptions(); options.setCleanSession(false); m_client.connect(options); m_client.subscribe...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void handleDisconnect(IoSession session, DisconnectMessage disconnectMessage) { String clientID = (String) session.getAttribute(ATTR_CLIENTID); //remove from clientIDs m_clientIDsLock.lock(); try { m_clientIDs.remove...
#fixed code protected void handleDisconnect(IoSession session, DisconnectMessage disconnectMessage) { String clientID = (String) session.getAttribute(ATTR_CLIENTID); //remove from clientIDs // m_clientIDsLock.lock(); // try { // m_clientIDs.remove...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void removeSubscription(String topic, String clientID) { TreeNode matchNode = findMatchingNode(topic); //search for the subscription to remove Subscription toBeRemoved = null; for (Subscription sub : matchNode.subscription...
#fixed code public void removeSubscription(String topic, String clientID) { TreeNode oldRoot; NodeCouple couple; do { oldRoot = subscriptions.get(); couple = recreatePath(topic, oldRoot); //do the job //search for t...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void handleConnect(IoSession session, ConnectMessage msg) { LOG.info("handleConnect invoked"); if (msg.getProcotolVersion() != 0x03) { ConnAckMessage badProto = new ConnAckMessage(); badProto.setReturnCode(ConnAckMessage...
#fixed code protected void handleConnect(IoSession session, ConnectMessage msg) { LOG.info("handleConnect invoked"); m_messaging.connect(session, msg); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void processInit(Properties props) { benchmarkEnabled = Boolean.parseBoolean(System.getProperty("moquette.processor.benchmark", "false")); //TODO use a property to select the storage path MapDBPersistentStore mapStorage = new MapDBPersis...
#fixed code private void processInit(Properties props) { benchmarkEnabled = Boolean.parseBoolean(System.getProperty("moquette.processor.benchmark", "false")); //TODO use a property to select the storage path MapDBPersistentStore mapStorage = new MapDBPersistentSt...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static GitRepositoryState getGitRepositoryState() throws IOException { Properties properties = new Properties(); try { properties.load(new FileInputStream("config/git.properties")); } catch (IOException e) { ...
#fixed code public static GitRepositoryState getGitRepositoryState() throws IOException { Properties properties = new Properties(); try { InputStream inputStream = new FileInputStream("config/git.properties"); BufferedReader bf = new BufferedReader...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void startServer(IConfig config, List<? extends InterceptHandler> handlers) throws IOException { startServer(config, handlers, null); } #location 2 #vulnerability type NULL_DEREFERENCE
#fixed code public void startServer(IConfig config, List<? extends InterceptHandler> handlers) throws IOException { startServer(config, handlers, null, null, null); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public WFCMessage.PullMessageResult fetchChatroomMessage(String fromUser, String chatroomId, String exceptClientId, long fromMessageId) { WFCMessage.PullMessageResult.Builder builder = WFCMessage.PullMessageResult.newBuilder(); HazelcastIn...
#fixed code @Override public WFCMessage.PullMessageResult fetchChatroomMessage(String fromUser, String chatroomId, String exceptClientId, long fromMessageId) { WFCMessage.PullMessageResult.Builder builder = WFCMessage.PullMessageResult.newBuilder(); HazelcastInstance...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void avoidMultipleNotificationsAfterMultipleReconnection_cleanSessionFalseQoS1() throws Exception { LOG.info("*** avoidMultipleNotificationsAfterMultipleReconnection_cleanSessionFalseQoS1, issue #16 ***"); MqttConnectOptions options = ne...
#fixed code @Test public void avoidMultipleNotificationsAfterMultipleReconnection_cleanSessionFalseQoS1() throws Exception { LOG.info("*** avoidMultipleNotificationsAfterMultipleReconnection_cleanSessionFalseQoS1, issue #16 ***"); MqttConnectOptions options = new Mqtt...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public int getNotifyReceivers(String fromUser, WFCMessage.Message.Builder messageBuilder, Set<String> notifyReceivers, boolean ignoreMsg) { WFCMessage.Message message = messageBuilder.build(); HazelcastInstance hzInstance = m_Server.getHaze...
#fixed code @Override public int getNotifyReceivers(String fromUser, WFCMessage.Message.Builder messageBuilder, Set<String> notifyReceivers, boolean ignoreMsg) { WFCMessage.Message message = messageBuilder.build(); HazelcastInstance hzInstance = m_Server.getHazelcastI...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void checkWillMessageIsWiredOnClientKeepAliveExpiry() throws Exception { LOG.info("*** checkWillMessageIsWiredOnClientKeepAliveExpiry ***"); String willTestamentTopic = "/will/test"; String willTestamentMsg = "Bye bye"; ...
#fixed code @Test public void checkWillMessageIsWiredOnClientKeepAliveExpiry() throws Exception { LOG.info("*** checkWillMessageIsWiredOnClientKeepAliveExpiry ***"); String willTestamentTopic = "/will/test"; String willTestamentMsg = "Bye bye"; ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public WFCMessage.Message getMessage(long messageId) { HazelcastInstance hzInstance = m_Server.getHazelcastInstance(); IMap<Long, MessageBundle> mIMap = hzInstance.getMap(MESSAGES_MAP); MessageBundle bundle = mIMap.get(messageId); ...
#fixed code @Override public WFCMessage.Message getMessage(long messageId) { HazelcastInstance hzInstance = m_Server.getHazelcastInstance(); IMap<Long, MessageBundle> mIMap = hzInstance.getMap(MESSAGES_MAP); MessageBundle bundle = mIMap.get(messageId); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { NettyChannel channel = m_channelMapper.get(ctx); String clientID = (String) channel.getAttribute(NettyChannel.ATTR_KEY_CLIENTID); m_messaging.lostConnection(c...
#fixed code @Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { // NettyChannel channel = m_channelMapper.get(ctx); // String clientID = (String) channel.getAttribute(NettyChannel.ATTR_KEY_CLIENTID); String clientID = (String) Net...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testPublishReceiveWithQoS2() throws Exception { LOG.info("*** testPublishReceiveWithQoS2 ***"); MqttConnectOptions options = new MqttConnectOptions(); options.setCleanSession(false); m_client.connect(options); ...
#fixed code @Test public void testPublishReceiveWithQoS2() throws Exception { LOG.info("*** testPublishReceiveWithQoS2 ***"); MqttConnectOptions options = new MqttConnectOptions(); options.setCleanSession(false); m_client.connect(options); m_cl...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void initialize(ProtocolProcessor processor, IConfig props, ISslContextCreator sslCtxCreator) throws IOException { LOG.info("Initializing Netty acceptor..."); nettySoBacklog = Integer.parseInt(props.getProperty(BrokerCon...
#fixed code @Override public void initialize(ProtocolProcessor processor, IConfig props, ISslContextCreator sslCtxCreator) throws IOException { LOG.info("Initializing Netty acceptor..."); nettySoBacklog = Integer.parseInt(props.getProperty(BrokerConstants...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public WFCMessage.PullMessageResult fetchMessage(String user, String exceptClientId, long fromMessageId, int pullType) { WFCMessage.PullMessageResult.Builder builder = WFCMessage.PullMessageResult.newBuilder(); HazelcastInstance hzInstance...
#fixed code @Override public WFCMessage.PullMessageResult fetchMessage(String user, String exceptClientId, long fromMessageId, int pullType) { WFCMessage.PullMessageResult.Builder builder = WFCMessage.PullMessageResult.newBuilder(); HazelcastInstance hzInstance = m_S...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void channelRead(ChannelHandlerContext ctx, Object message) { AbstractMessage msg = (AbstractMessage) message; LOG.info("Received a message of type {}", Utils.msgType2String(msg.getMessageType())); try { switch (m...
#fixed code @Override public void channelRead(ChannelHandlerContext ctx, Object message) { AbstractMessage msg = (AbstractMessage) message; LOG.info("Received a message of type {}", Utils.msgType2String(msg.getMessageType())); try { switch (msg.get...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public ErrorCode handleFriendRequest(String userId, WFCMessage.HandleFriendRequest request, WFCMessage.Message.Builder msgBuilder, long[] heads, boolean isAdmin) { HazelcastInstance hzInstance = m_Server.getHazelcastInstance(); if (isAdmin...
#fixed code @Override public ErrorCode handleFriendRequest(String userId, WFCMessage.HandleFriendRequest request, WFCMessage.Message.Builder msgBuilder, long[] heads, boolean isAdmin) { HazelcastInstance hzInstance = m_Server.getHazelcastInstance(); if (isAdmin) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void run() { m_startMillis = System.currentTimeMillis(); MQTT mqtt = new MQTT(); try { // mqtt.setHost("test.mosquitto.org", 1883); mqtt.setHost("localhost", 1883); } catch (URISyntaxException ex) { ...
#fixed code public void run() { m_startMillis = System.currentTimeMillis(); MQTT mqtt = new MQTT(); try { // mqtt.setHost("test.mosquitto.org", 1883); mqtt.setHost("localhost", 1883); } catch (URISyntaxException ex) { LOG...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testLazyLoading() throws Exception { final AtomicBoolean requestWasSent = new AtomicBoolean(false); TestableConnectionProvider provider = new TestableConnectionProvider() { @Override public void sendRequest(...
#fixed code @Test public void testLazyLoading() throws Exception { final AtomicBoolean requestWasSent = new AtomicBoolean(false); TestableConnectionProvider provider = new TestableConnectionProvider() { @Override public void sendRequest(URL ur...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testRestoreChallenge() throws AcmeException { Connection connection = new DummyConnection() { @Override public int sendRequest(URI uri) throws AcmeException { assertThat(uri, is(locationUri)); ...
#fixed code @Test public void testRestoreChallenge() throws AcmeException { Connection connection = new DummyConnection() { @Override public int sendRequest(URI uri) { assertThat(uri, is(locationUri)); return HttpURLConn...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private List<Challenge> fetchChallenges(JSON json) { JSON.Array jsonChallenges = json.get("challenges").asArray(); List<Challenge> cr = new ArrayList<>(); for (JSON.Value c : jsonChallenges) { Challenge ch = getSession().createChallen...
#fixed code private List<Challenge> fetchChallenges(JSON json) { Session session = getSession(); return Collections.unmodifiableList(json.get("challenges").asArray().stream() .map(JSON.Value::asObject) .map(session::createChallenge) ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testNewAuthorization() throws AcmeException { Authorization auth = new Authorization(); auth.setDomain("example.org"); Connection connection = new DummyConnection() { @Override public int sendSignedR...
#fixed code @Test public void testNewAuthorization() throws AcmeException { Authorization auth = new Authorization(); auth.setDomain("example.org"); Connection connection = new DummyConnection() { @Override public int sendSignedRequest...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testUpdate() throws Exception { TestableConnectionProvider provider = new TestableConnectionProvider() { @Override public void sendRequest(URL url, Session session) { assertThat(url, is(locationUrl));...
#fixed code @Test public void testUpdate() throws Exception { TestableConnectionProvider provider = new TestableConnectionProvider() { @Override public void sendRequest(URL url, Session session) { assertThat(url, is(locationUrl)); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private List<Challenge> fetchChallenges(JSON json) { JSON.Array jsonChallenges = json.get("challenges").asArray(); List<Challenge> cr = new ArrayList<>(); for (JSON.Value c : jsonChallenges) { Challenge ch = getSession().createChallen...
#fixed code private List<Challenge> fetchChallenges(JSON json) { Session session = getSession(); return Collections.unmodifiableList(json.get("challenges").asArray().stream() .map(JSON.Value::asObject) .map(session::createChallenge) ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testAuthorizeBadDomain() throws Exception { TestableConnectionProvider provider = new TestableConnectionProvider(); Session session = provider.createSession(); Registration registration = Registration.bind(session, locationU...
#fixed code @Test public void testAuthorizeBadDomain() throws Exception { TestableConnectionProvider provider = new TestableConnectionProvider(); // just provide a resource record so the provider returns a directory provider.putTestResource(Resource.NEW_NONCE,...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testSendRequest() throws Exception { when(mockUrlConnection.getResponseCode()).thenReturn(HttpURLConnection.HTTP_OK); try (DefaultConnection conn = new DefaultConnection(mockHttpConnection)) { conn.sendRequest(requestUr...
#fixed code @Test public void testSendRequest() throws Exception { when(mockUrlConnection.getResponseCode()).thenReturn(HttpURLConnection.HTTP_OK); try (DefaultConnection conn = new DefaultConnection(mockHttpConnection) { @Override public Stri...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testUpdateRetryAfter() throws Exception { final Instant retryAfter = Instant.now().plus(Duration.ofSeconds(30)); TestableConnectionProvider provider = new TestableConnectionProvider() { @Override public void...
#fixed code @Test public void testUpdateRetryAfter() throws Exception { final Instant retryAfter = Instant.now().plus(Duration.ofSeconds(30)); TestableConnectionProvider provider = new TestableConnectionProvider() { @Override public void sendR...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testSendCertificateRequest() throws Exception { when(mockUrlConnection.getResponseCode()).thenReturn(HttpURLConnection.HTTP_OK); try (DefaultConnection conn = new DefaultConnection(mockHttpConnection)) { conn.sendCertif...
#fixed code @Test public void testSendCertificateRequest() throws Exception { final String nonce1 = Base64Url.encode("foo-nonce-1-foo".getBytes()); final String nonce2 = Base64Url.encode("foo-nonce-2-foo".getBytes()); final ByteArrayOutputStream outputStream =...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testArray() { JSON json = TestUtils.getJsonAsObject("json"); JSON.Array array = json.get("array").asArray(); assertThat(array.size(), is(4)); assertThat(array.get(0), is(notNullValue())); assertThat(array.ge...
#fixed code @Test public void testArray() { JSON json = TestUtils.getJsonAsObject("json"); JSON.Array array = json.get("array").asArray(); assertThat(array.size(), is(4)); assertThat(array.isEmpty(), is(false)); assertThat(array.get(0), is(not...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void throwAcmeException() throws AcmeException { try { String contentType = AcmeUtils.getContentType(conn.getHeaderField(CONTENT_TYPE_HEADER)); if (!"application/problem+json".equals(contentType)) { throw new AcmeE...
#fixed code private void throwAcmeException() throws AcmeException { try { String contentType = AcmeUtils.getContentType(conn.getHeaderField(CONTENT_TYPE_HEADER)); if (!"application/problem+json".equals(contentType)) { throw new AcmeExcepti...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testSendRequest() throws Exception { when(mockUrlConnection.getResponseCode()).thenReturn(HttpURLConnection.HTTP_OK); try (DefaultConnection conn = new DefaultConnection(mockHttpConnection)) { conn.sendRequest(requestUr...
#fixed code @Test public void testSendRequest() throws Exception { when(mockUrlConnection.getResponseCode()).thenReturn(HttpURLConnection.HTTP_OK); try (DefaultConnection conn = new DefaultConnection(mockHttpConnection) { @Override public Stri...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private AcmeException createAcmeException(Problem problem) { if (problem.getType() == null) { return new AcmeException(problem.getDetail()); } String error = AcmeUtils.stripErrorPrefix(problem.getType().toString()); if ("una...
#fixed code private AcmeException createAcmeException(Problem problem) { if (problem.getType() == null) { return new AcmeException(problem.getDetail()); } String error = AcmeUtils.stripErrorPrefix(problem.getType().toString()); if ("unauthori...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public AcmeProvider provider() { synchronized (this) { if (provider == null) { List<AcmeProvider> candidates = new ArrayList<>(); for (AcmeProvider acp : ServiceLoader.load(AcmeProvider.class)) { if...
#fixed code public AcmeProvider provider() { return provider; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testSendCertificateRequest() throws Exception { when(mockUrlConnection.getResponseCode()).thenReturn(HttpURLConnection.HTTP_OK); try (DefaultConnection conn = new DefaultConnection(mockHttpConnection)) { conn.sendCertif...
#fixed code @Test public void testSendCertificateRequest() throws Exception { final String nonce1 = Base64Url.encode("foo-nonce-1-foo".getBytes()); final String nonce2 = Base64Url.encode("foo-nonce-2-foo".getBytes()); final ByteArrayOutputStream outputStream =...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public int accept(int... httpStatus) throws AcmeException { assertConnectionIsOpen(); try { int rc = conn.getResponseCode(); OptionalInt match = Arrays.stream(httpStatus).filter(s -> s == rc).findFirst(); ...
#fixed code @Override public int accept(int... httpStatus) throws AcmeException { assertConnectionIsOpen(); try { int rc = conn.getResponseCode(); OptionalInt match = Arrays.stream(httpStatus).filter(s -> s == rc).findFirst(); if (...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public HttpURLConnection openConnection(URL url, Proxy proxy) throws IOException { HttpURLConnection conn = super.openConnection(url, proxy); if (conn instanceof HttpsURLConnection) { ((HttpsURLConnection) conn).setSSLSocketFact...
#fixed code @Override public HttpURLConnection openConnection(URL url, Proxy proxy) throws IOException { HttpURLConnection conn = super.openConnection(url, proxy); if (conn instanceof HttpsURLConnection) { HttpsURLConnection conns = (HttpsURLConnection) co...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public int sendSignedRequest(URI uri, ClaimBuilder claims, Session session, Registration registration) throws AcmeException { if (uri == null) { throw new NullPointerException("uri must not be null"); } i...
#fixed code @Override public int sendSignedRequest(URI uri, ClaimBuilder claims, Session session, Registration registration) throws AcmeException { if (uri == null) { throw new NullPointerException("uri must not be null"); } if (cla...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @GetMapping("/employees/{id}") public Mono<EntityModel<Employee>> findOne(@PathVariable Integer id) { WebFluxEmployeeController controller = methodOn(WebFluxEmployeeController.class); Mono<Link> selfLink = linkTo(controller.findOne(id)).withSelfRel() // .andAffo...
#fixed code @GetMapping("/employees/{id}") public Mono<EntityModel<Employee>> findOne(@PathVariable Integer id) { WebFluxEmployeeController controller = methodOn(WebFluxEmployeeController.class); Mono<Link> selfLink = linkTo(controller.findOne(id)).withSelfRel() // .andAffordance...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static HalLinkRelation of(@Nullable LinkRelation relation) { Assert.notNull(relation, "LinkRelation must not be null!"); if (HalLinkRelation.class.isInstance(relation)) { return HalLinkRelation.class.cast(relation); } return of(relation.value()); } ...
#fixed code public static HalLinkRelation of(@Nullable LinkRelation relation) { Assert.notNull(relation, "LinkRelation must not be null!"); if (relation instanceof HalLinkRelation) { return (HalLinkRelation) relation; } return of(relation.value()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static UriComponentsBuilder getBuilder() { if (RequestContextHolder.getRequestAttributes() == null) { return UriComponentsBuilder.fromPath("/"); } HttpServletRequest request = getCurrentRequest(); UriComponentsBuilder builder = ServletUriComponentsBuild...
#fixed code public static UriComponentsBuilder getBuilder() { if (RequestContextHolder.getRequestAttributes() == null) { return UriComponentsBuilder.fromPath("/"); } HttpServletRequest request = getCurrentRequest(); ServletUriComponentsBuilder builder = ServletUriComponentsBuil...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(String... args) { RestTemplate template = new RestTemplate(); HttpEntity<String> response = template.getForEntity(URI_TEMPLATE, String.class, MILESTONE_ID); boolean keepChecking = true; boolean printHeader = true; while (keepChecking) ...
#fixed code public static void main(String... args) { /* * If you run into github rate limiting issues, you can always use a Github Personal Token by adding * {@code .header(HttpHeaders.AUTHORIZATION, "token your-github-token")} to the webClient call. */ WebClient webClient =...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static UriComponentsBuilder getBuilder() { if (RequestContextHolder.getRequestAttributes() == null) { return UriComponentsBuilder.fromPath("/"); } HttpServletRequest request = getCurrentRequest(); ServletUriComponentsBuilder builder = ServletUriComponen...
#fixed code public static UriComponentsBuilder getBuilder() { if (RequestContextHolder.getRequestAttributes() == null) { return UriComponentsBuilder.fromPath("/"); } return ServletUriComponentsBuilder.fromServletMapping(getCurrentRequest()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testCreate() throws IOException { Dataset dataset = repo.create("test1", testSchema); Assert.assertTrue("Dataset data directory exists", fileSystem.exists(new Path(testDirectory, "data/test1/data"))); Assert.assertTrue("Dataset met...
#fixed code @Test public void testCreate() throws IOException { HDFSDataset dataset = repo.create("test1", testSchema); Assert.assertTrue("HDFSDataset data directory exists", fileSystem.exists(new Path(testDirectory, "data/test1/data"))); Assert.assertTrue("HDFSDatas...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public List<Word> segImpl(String text) { if(text.length() > PROCESS_TEXT_LENGTH_LESS_THAN){ return RMM.segImpl(text); } //获取全切分结果 List<Word>[] array = fullSeg(text); //利用ngram计算分值 Map<List<Word>, ...
#fixed code @Override public List<Word> segImpl(String text) { //文本长度 final int textLen = text.length(); //开始虚拟节点,注意值的长度只能为1 Node start = new Node("S", 0); start.score = 1F; //结束虚拟节点 Node end = new Node("END", textLen+1); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testGet() { Assert.assertEquals(100, trie.get("杨尚川"), 0); Assert.assertEquals(99, trie.get("杨尚喜"), 0); Assert.assertEquals(98, trie.get("杨尚丽"), 0); Assert.assertEquals(1, trie.get("中华人民共和国"), 0); Assert.asser...
#fixed code @Test public void testGet() { assertEquals(100, genericTrie.get("杨尚川").intValue()); assertEquals(99, genericTrie.get("杨尚喜").intValue()); assertEquals(98, genericTrie.get("杨尚丽").intValue()); assertEquals(1, genericTrie.get("中华人民共和国").intValu...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public List<Word> seg(String text) { List<Word> result = new ArrayList<>(); List<String> sentences = Punctuation.seg(text, KEEP_PUNCTUATION); if(sentences.size() == 1){ result = segSentence(sentences.get(0)); }el...
#fixed code @Override public List<Word> seg(String text) { List<String> sentences = Punctuation.seg(text, KEEP_PUNCTUATION); if(sentences.size() == 1){ return segSentence(sentences.get(0)); } //如果是多个句子,可以利用多线程提升分词速度 List<Future<List...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testClear() { Assert.assertEquals(100, trie.get("杨尚川"), 0); Assert.assertEquals(1, trie.get("中华人民共和国"), 0); trie.clear(); Assert.assertEquals(null, trie.get("杨尚川")); Assert.assertEquals(null, trie.get("中华人民共和...
#fixed code @Test public void testClear() { assertEquals(100, genericTrie.get("杨尚川").intValue()); assertEquals(1, genericTrie.get("中华人民共和国").intValue()); genericTrie.clear(); assertEquals(null, genericTrie.get("杨尚川")); assertEquals(null, generi...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public List<Word> segImpl(String text) { if(text.length() > PROCESS_TEXT_LENGTH_LESS_THAN){ return RMM.segImpl(text); } //获取全切分结果 List<Word>[] array = fullSeg(text); //利用ngram计算分值 Map<List<Word>, ...
#fixed code @Override public List<Word> segImpl(String text) { if(text.length() > PROCESS_TEXT_LENGTH_LESS_THAN){ return RMM.segImpl(text); } //获取全切分结果 List<Word>[] array = fullSeg(text); Set<Word> words = new HashSet<Word>(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public final boolean incrementToken() throws IOException { Word word = getWord(); if (word != null) { int positionIncrement = 1; //忽略停用词 while(StopWord.is(word.getText())){ positionIncreme...
#fixed code @Override public final boolean incrementToken() throws IOException { String token = getToken(); if (token != null) { charTermAttribute.setEmpty().append(token); return true; } return false; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override protected void doStartProxy(KubernetesContainerProxy proxy) throws Exception { String kubeNamespace = getProperty(PROPERTY_NAMESPACE, proxy.getApp(), DEFAULT_NAMESPACE); String[] volumeStrings = Optional.ofNullable(proxy.getApp().getDockerVolumes()).orEls...
#fixed code @Override protected void doStartProxy(KubernetesContainerProxy proxy) throws Exception { String kubeNamespace = getProperty(PROPERTY_NAMESPACE, proxy.getApp(), DEFAULT_NAMESPACE); String apiVersion = getProperty(PROPERTY_API_VERSION, proxy.getApp(), DEFAULT_API_VERSION); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public HttpResponse execute(HttpRequest request) throws HttpClientException { HttpResponse response = null; try { URI uri = new URI(request.getURI().toString(), false, Consts.UTF_8.name()); org.apache.commons.httpclient.HttpMethod httpMethod = met...
#fixed code @Override public HttpResponse execute(HttpRequest request) throws HttpClientException { HttpResponse response = null; try { URI uri = new URI(request.getURI().toString(), false, Consts.UTF_8.name()); org.apache.commons.httpclient.HttpMethod httpMethod = method2me...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public MchPayRequest createMicroPayRequest(String authCode, String body, String outTradeNo, double totalFee, String createIp, String attach) throws WeixinException { // 刷卡支付不需要设置TradeType.MICROPAY MchPayPackage payPackage = new MchPayPackage(body, outTradeNo, ...
#fixed code public MchPayRequest createMicroPayRequest(String authCode, String body, String outTradeNo, double totalFee, String createIp, String attach) throws WeixinException { MchPayPackage payPackage = new MchPayPackage(body, outTradeNo, totalFee, null, createIp, TradeType.MI...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Order orderQuery(IdQuery idQuery) throws WeixinException { Map<String, String> map = baseMap(idQuery); String sign = PayUtil.paysignMd5(map, weixinAccount.getPaySignKey()); map.put("sign", sign); String param = XmlStream.map2xml(map); String orderquery_uri...
#fixed code public Order orderQuery(IdQuery idQuery) throws WeixinException { Map<String, String> map = baseMap(idQuery); String sign = PayUtil.paysignMd5(map, weixinAccount.getPaySignKey()); map.put("sign", sign); String param = XmlStream.map2xml(map); String orderquery_uri = get...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public HttpResponse execute(HttpRequest request) throws HttpClientException { HttpResponse response = null; try { URI uri = new URI(request.getURI().toString(), false, Consts.UTF_8.name()); org.apache.commons.httpclient.HttpMethod httpMethod = met...
#fixed code @Override public HttpResponse execute(HttpRequest request) throws HttpClientException { HttpResponse response = null; try { org.apache.commons.httpclient.HttpMethod httpMethod = createHttpMethod( request.getMethod(), request.getURI()); boolean useSSL = "https".eq...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static List<Class<?>> getClasses(String packageName) { String packageFileName = packageName.replace(POINT, File.separator); URL fullPath = getDefaultClassLoader().getResource(packageFileName); if (fullPath == null) { fullPath = ClassUtil.class.getClassLoade...
#fixed code public static List<Class<?>> getClasses(String packageName) { String packageFileName = packageName.replace(POINT, File.separator); URL fullPath = getDefaultClassLoader().getResource(packageFileName); if (fullPath == null) { fullPath = ClassUtil.class.getProtectionDomain...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Order orderQuery(IdQuery idQuery) throws WeixinException { Map<String, String> map = baseMap(idQuery); String sign = PayUtil.paysignMd5(map, weixinAccount.getPaySignKey()); map.put("sign", sign); String param = XmlStream.map2xml(map); String orderquery_uri...
#fixed code public Order orderQuery(IdQuery idQuery) throws WeixinException { Map<String, String> map = baseMap(idQuery); String sign = PayUtil.paysignMd5(map, weixinAccount.getPaySignKey()); map.put("sign", sign); String param = XmlStream.map2xml(map); String orderquery_uri = get...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void sendMessage(String ircCatHost, int ircCatPort, String message, String channel) throws IOException { Socket socket = new Socket(ircCatHost, ircCatPort); Writer out = new OutputStreamWriter(socket.getOutputStream()); try { ...
#fixed code private void sendMessage(String ircCatHost, int ircCatPort, String message, String channel) throws IOException { Socket socket = new Socket(ircCatHost, ircCatPort); Closer closer = Closer.create(); try { Writer out = closer.register(new Out...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void sendMessage(String ircCatHost, int ircCatPort, String message, String channel) throws IOException { Socket socket = new Socket(ircCatHost, ircCatPort); Writer out = new OutputStreamWriter(socket.getOutputStream()); try { ...
#fixed code private void sendMessage(String ircCatHost, int ircCatPort, String message, String channel) throws IOException { Socket socket = new Socket(ircCatHost, ircCatPort); Closer closer = Closer.create(); try { Writer out = closer.register(new Out...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public RulesProfile createProfile(final ValidationMessages messages) { LOGGER.info("Creating Swift Profile"); Reader config = null; final RulesProfile profile = RulesProfile.create("Swift", Swift.KEY); profile.setDefaultProfile(true); try { // ad...
#fixed code @Override public RulesProfile createProfile(final ValidationMessages messages) { LOGGER.info("Creating Swift Profile"); Reader config = null; final RulesProfile profile = RulesProfile.create("Swift", Swift.KEY); profile.setDefaultProfile(true); try { // Add swif...
Below is the vulnerable code, please generate the patch based on the following information.