output
stringlengths
64
73.2k
input
stringlengths
208
73.3k
instruction
stringclasses
1 value
#fixed code public static void main(String[] args) throws Exception { if (args.length < 1){ System.out.println("usage: <index location> <command> <command args>"); System.exit(1); } String idxLocation = args[0]; ClueApplication app = null; if ...
#vulnerable code public static void main(String[] args) throws Exception { if (args.length < 1){ System.out.println("usage: <index location> <command> <command args>"); System.exit(1); } ClueConfiguration config = ClueConfiguration.load(); String idxL...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static void main(String[] args) throws Exception { if (args.length < 1){ System.out.println("usage: <index location> <command> <command args>"); System.exit(1); } String idxLocation = args[0]; ClueApplication app = null; if ...
#vulnerable code public static void main(String[] args) throws Exception { if (args.length < 1){ System.out.println("usage: <index location> <command> <command args>"); System.exit(1); } String idxLocation = args[0]; ClueApplication app = null; ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static void printScreen() { if (error == null || error || !error) { printScreenWithOld(); } else { try { String[] args = new String[]{"bash", "-c", adbPath + " exec-out screencap -p > " + screenshotLocation}; ...
#vulnerable code public static void printScreen() { if (error != null && error) { printScreenWithOld(); } else { try { String[] args = new String[]{"bash", "-c", adbPath + " exec-out screencap -p > " + screenshotLocation}; ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static void printScreen() { if (error == null || error || !error) { printScreenWithOld(); } else { try { String[] args = new String[]{"bash", "-c", adbPath + " exec-out screencap -p > " + screenshotLocation}; ...
#vulnerable code public static void printScreen() { if (error != null && error) { printScreenWithOld(); } else { try { String[] args = new String[]{"bash", "-c", adbPath + " exec-out screencap -p > " + screenshotLocation}; ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static void buildSysGenProfilingFile() { long startMills = System.currentTimeMillis(); String filePath = ProfilingConfig.getInstance().getSysProfilingParamsFile(); String tempFilePath = filePath + "_tmp"; File tempFile = new File(tempFil...
#vulnerable code public static void buildSysGenProfilingFile() { long startMills = System.currentTimeMillis(); String filePath = ProfilingConfig.getInstance().getSysProfilingParamsFile(); String tempFilePath = filePath + "_tmp"; File tempFile = new File(t...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test void authenticationStepsShouldAuthenticatePushModeWithProvidedSecretId() { String roleId = getRoleId("with-secret-id"); String secretId = "hello_world_two"; VaultResponse customSecretIdResponse = getVaultOperations().write( "auth/approle/role/with-secret-id/cu...
#vulnerable code @Test void authenticationStepsShouldAuthenticatePushModeWithProvidedSecretId() { String roleId = getRoleId("with-secret-id"); String secretId = "hello_world_two"; VaultResponse customSecretIdResponse = getVaultOperations().write( "auth/approle/role/with-secret...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @SuppressWarnings("unchecked") private Lease renew(Lease lease) { return operations.doWithSession(restOperations -> leaseEndpoints.renew(lease, restOperations)); }
#vulnerable code @SuppressWarnings("unchecked") private Lease renew(Lease lease) { HttpEntity<Object> leaseRenewalEntity = getLeaseRenewalBody(lease); ResponseEntity<Map<String, Object>> entity = operations .doWithSession(restOperations -> (ResponseEntity) restOperations ....
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override @SuppressWarnings("unchecked") public boolean isInitialized() { return requireResponse(vaultOperations.doWithSession(restOperations -> { try { ResponseEntity<Map<String, Boolean>> body = (ResponseEntity) restOperations .exchange("sys/init", HttpMetho...
#vulnerable code @Override @SuppressWarnings("unchecked") public boolean isInitialized() { return requireResponse(vaultOperations.doWithVault(restOperations -> { try { Map<String, Boolean> body = restOperations.getForObject("sys/init", Map.class); Assert.state(body ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test void shouldAuthenticatePullModeWithGeneratedSecretId() { String roleId = getRoleId("with-secret-id"); String secretId = (String) getVaultOperations() .write(String.format("auth/approle/role/%s/secret-id", "with-secret-id"), null).getRequiredData().get("secr...
#vulnerable code @Test void shouldAuthenticatePullModeWithGeneratedSecretId() { String roleId = getRoleId("with-secret-id"); String secretId = (String) getVaultOperations() .write(String.format("auth/approle/role/%s/secret-id", "with-secret-id"), null).getRequiredData().get...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public boolean initForceBatchStatementsOrdering(TypedMap configMap) { return configMap.getTypedOr(FORCE_BATCH_STATEMENTS_ORDERING, DEFAULT_FORCE_BATCH_STATEMENTS_ORDERING); }
#vulnerable code public boolean initForceBatchStatementsOrdering(TypedMap configMap) { return configMap.getTypedOr(FORCE_BATCH_STATEMENTS_ORDERING, true); } #location 2 #vulnerability type NULL_DEREFERENCE
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private TypeParsingResult parseComputedType(AnnotationTree annotationTree, FieldParsingContext context, TypeName sourceType) { final CodecInfo codecInfo = codecFactory.createCodec(sourceType, annotationTree, context, Optional.empty()); final TypeName rawTarget...
#vulnerable code private TypeParsingResult parseComputedType(AnnotationTree annotationTree, FieldParsingContext context, TypeName sourceType) { final CodecInfo codecInfo = codecFactory.createCodec(sourceType, annotationTree, context); final TypeName rawTargetType = getRa...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public PreparedStatement prepareUpdateFields(Session session, EntityMeta entityMeta, List<PropertyMeta> pms) { log.trace("Generate prepared statement for UPDATE properties {}", pms); PropertyMeta idMeta = entityMeta.getIdMeta(); Update update = update(entityMeta.getTable...
#vulnerable code public PreparedStatement prepareUpdateFields(Session session, EntityMeta entityMeta, List<PropertyMeta> pms) { log.trace("Generate prepared statement for UPDATE properties {}", pms); PropertyMeta idMeta = entityMeta.getIdMeta(); Update update = update(entityMeta.ge...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void addInterceptorsToEntityMetas(List<Interceptor<?>> interceptors, Map<Class<?>, EntityMeta> entityMetaMap) { for (Interceptor<?> interceptor : interceptors) { Class<?> parentEntityClass = propertyParser.inferEntityClassFromInterceptor...
#vulnerable code public void addInterceptorsToEntityMetas(List<Interceptor<?>> interceptors, Map<Class<?>, EntityMeta> entityMetaMap) { for (Interceptor<?> interceptor : interceptors) { Class<?> entityClass = propertyParser.inferEntityClassFromInterceptor...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public Map<CQLQueryType, PreparedStatement> prepareClusteredCounterQueryMap(Session session, EntityMeta meta) { PropertyMeta idMeta = meta.getIdMeta(); PropertyMeta counterMeta = meta.getFirstMeta(); String tableName = meta.getTableName(); String counterName = counterMet...
#vulnerable code public Map<CQLQueryType, PreparedStatement> prepareClusteredCounterQueryMap(Session session, EntityMeta meta) { PropertyMeta idMeta = meta.getIdMeta(); PropertyMeta counterMeta = meta.getFirstMeta(); String tableName = meta.getTableName(); String counterName = coun...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) { final boolean kubernetesEnabled = environment .getProperty("spring.cloud.kubernetes.enabled", Boolean.class, true); if (!kubernetesEnabled) { return...
#vulnerable code @Override public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) { final boolean kubernetesEnabled = environment .getProperty("spring.cloud.kubernetes.enabled", Boolean.class, true); if (!kubernetesEnabled) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testDecodeWithMessageIdAndAck() throws IOException { Packet packet = decoder.decodePackets(Unpooled.copiedBuffer("5:1+::{\"name\":\"tobi\"}", CharsetUtil.UTF_8), null); Assert.assertEquals(PacketType.EVENT, packet.getType()); // As...
#vulnerable code @Test public void testDecodeWithMessageIdAndAck() throws IOException { Packet packet = decoder.decodePacket("5:1+::{\"name\":\"tobi\"}", null); Assert.assertEquals(PacketType.EVENT, packet.getType()); // Assert.assertEquals(1, (long)packet.get...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { if (msg instanceof FullHttpRequest) { FullHttpRequest req = (FullHttpRequest) msg; QueryStringDecoder queryDecoder = new QueryStringDecoder(req.getUri()); String resource = r...
#vulnerable code @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { if (msg instanceof FullHttpRequest) { FullHttpRequest req = (FullHttpRequest) msg; QueryStringDecoder queryDecoder = new QueryStringDecoder(req.getUri()); File resource...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void disconnect() { ChannelFuture future = send(new Packet(PacketType.DISCONNECT)); if(future != null) { future.addListener(ChannelFutureListener.CLOSE); } onChannelDisconnect(); }
#vulnerable code public void disconnect() { ChannelFuture future = send(new Packet(PacketType.DISCONNECT)); future.addListener(ChannelFutureListener.CLOSE); onChannelDisconnect(); } #location 3 #vulne...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testDecode() throws IOException { Packet packet = decoder.decodePackets(Unpooled.copiedBuffer("5:::{\"name\":\"woot\"}", CharsetUtil.UTF_8), null); Assert.assertEquals(PacketType.EVENT, packet.getType()); Assert.assertEquals("woot...
#vulnerable code @Test public void testDecode() throws IOException { Packet packet = decoder.decodePacket("5:::{\"name\":\"woot\"}", null); Assert.assertEquals(PacketType.EVENT, packet.getType()); Assert.assertEquals("woot", packet.getName()); } ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void encodePacket(Packet packet, ByteBuf buffer, ByteBufAllocator allocator, boolean binary, boolean jsonp) throws IOException { ByteBuf buf = buffer; if (!binary) { buf = allocateBuffer(allocator); } byte type = toChar(packe...
#vulnerable code public void encodePacket(Packet packet, ByteBuf buffer, ByteBufAllocator allocator, boolean binary, boolean jsonp) throws IOException { ByteBuf buf = buffer; if (!binary) { buf = allocateBuffer(allocator); } byte type = toChar...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testDecodeDisconnection() throws IOException { Packet packet = decoder.decodePackets(Unpooled.copiedBuffer("0::/woot", CharsetUtil.UTF_8), null); Assert.assertEquals(PacketType.DISCONNECT, packet.getType()); Assert.assertEquals("/...
#vulnerable code @Test public void testDecodeDisconnection() throws IOException { Packet packet = decoder.decodePacket("0::/woot", null); Assert.assertEquals(PacketType.DISCONNECT, packet.getType()); Assert.assertEquals("/woot", packet.getNsp()); } ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testDecode() throws IOException { Packet packet = decoder.decodePackets(Unpooled.copiedBuffer("3:::woot", CharsetUtil.UTF_8), null); Assert.assertEquals(PacketType.MESSAGE, packet.getType()); Assert.assertEquals("woot", packet.get...
#vulnerable code @Test public void testDecode() throws IOException { Packet packet = decoder.decodePacket("3:::woot", null); Assert.assertEquals(PacketType.MESSAGE, packet.getType()); Assert.assertEquals("woot", packet.getData()); } ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testDecodeWithData() throws IOException { JacksonJsonSupport jsonSupport = new JacksonJsonSupport(); jsonSupport.addEventMapping("", "edwald", HashMap.class, Integer.class, String.class); PacketDecoder decoder = new PacketDecoder(...
#vulnerable code @Test public void testDecodeWithData() throws IOException { JacksonJsonSupport jsonSupport = new JacksonJsonSupport(); jsonSupport.addEventMapping("", "edwald", HashMap.class, Integer.class, String.class); PacketDecoder decoder = new PacketDe...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testDecodeWithMessageIdAndAckData() throws IOException { Packet packet = decoder.decodePackets(Unpooled.copiedBuffer("4:1+::{\"a\":\"b\"}", CharsetUtil.UTF_8), null); // Assert.assertEquals(PacketType.JSON, packet.getType()); // Ass...
#vulnerable code @Test public void testDecodeWithMessageIdAndAckData() throws IOException { Packet packet = decoder.decodePacket("4:1+::{\"a\":\"b\"}", null); // Assert.assertEquals(PacketType.JSON, packet.getType()); // Assert.assertEquals(1, (long)packet.getI...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testUTF8Decode() throws IOException { Packet packet = decoder.decodePackets(Unpooled.copiedBuffer("4:::\"Привет\"", CharsetUtil.UTF_8), null); // Assert.assertEquals(PacketType.JSON, packet.getType()); Assert.assertEquals("Привет",...
#vulnerable code @Test public void testUTF8Decode() throws IOException { Packet packet = decoder.decodePacket("4:::\"Привет\"", null); // Assert.assertEquals(PacketType.JSON, packet.getType()); Assert.assertEquals("Привет", packet.getData()); } ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testDecodeId() throws IOException { Packet packet = decoder.decodePackets(Unpooled.copiedBuffer("3:1::asdfasdf", CharsetUtil.UTF_8), null); Assert.assertEquals(PacketType.MESSAGE, packet.getType()); // Assert.assertEquals(1, (long)...
#vulnerable code @Test public void testDecodeId() throws IOException { Packet packet = decoder.decodePacket("3:1::asdfasdf", null); Assert.assertEquals(PacketType.MESSAGE, packet.getType()); // Assert.assertEquals(1, (long)packet.getId()); // Assert.ass...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testDecodeWithQueryString() throws IOException { Packet packet = decoder.decodePackets(Unpooled.copiedBuffer("1::/test:?test=1", CharsetUtil.UTF_8), null); Assert.assertEquals(PacketType.CONNECT, packet.getType()); Assert.assertEq...
#vulnerable code @Test public void testDecodeWithQueryString() throws IOException { Packet packet = decoder.decodePacket("1::/test:?test=1", null); Assert.assertEquals(PacketType.CONNECT, packet.getType()); Assert.assertEquals("/test", packet.getNsp()); // ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testDecode() throws IOException { Packet packet = decoder.decodePackets(Unpooled.copiedBuffer("6:::140", CharsetUtil.UTF_8), null); Assert.assertEquals(PacketType.ACK, packet.getType()); Assert.assertEquals(140, (long)packet.getAc...
#vulnerable code @Test public void testDecode() throws IOException { Packet packet = decoder.decodePacket("6:::140", null); Assert.assertEquals(PacketType.ACK, packet.getType()); Assert.assertEquals(140, (long)packet.getAckId()); // Assert.assertTrue(p...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testDecodingNewline() throws IOException { Packet packet = decoder.decodePackets(Unpooled.copiedBuffer("3:::\n", CharsetUtil.UTF_8), null); Assert.assertEquals(PacketType.MESSAGE, packet.getType()); Assert.assertEquals("\n", packe...
#vulnerable code @Test public void testDecodingNewline() throws IOException { Packet packet = decoder.decodePacket("3:::\n", null); Assert.assertEquals(PacketType.MESSAGE, packet.getType()); Assert.assertEquals("\n", packet.getData()); } ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testDecode() throws IOException { Packet packet = decoder.decodePackets(Unpooled.copiedBuffer("4:::\"2\"", CharsetUtil.UTF_8), null); // Assert.assertEquals(PacketType.JSON, packet.getType()); Assert.assertEquals("2", packet.getDat...
#vulnerable code @Test public void testDecode() throws IOException { Packet packet = decoder.decodePacket("4:::\"2\"", null); // Assert.assertEquals(PacketType.JSON, packet.getType()); Assert.assertEquals("2", packet.getData()); } ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testDecodeWithIdAndEndpoint() throws IOException { Packet packet = decoder.decodePackets(Unpooled.copiedBuffer("3:5:/tobi", CharsetUtil.UTF_8), null); Assert.assertEquals(PacketType.MESSAGE, packet.getType()); // Assert.assertEqual...
#vulnerable code @Test public void testDecodeWithIdAndEndpoint() throws IOException { Packet packet = decoder.decodePacket("3:5:/tobi", null); Assert.assertEquals(PacketType.MESSAGE, packet.getType()); // Assert.assertEquals(5, (long)packet.getId()); // ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { if (msg instanceof FullHttpRequest) { FullHttpRequest req = (FullHttpRequest) msg; QueryStringDecoder queryDecoder = new QueryStringDecoder(req.getUri()); String resource = r...
#vulnerable code @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { if (msg instanceof FullHttpRequest) { FullHttpRequest req = (FullHttpRequest) msg; QueryStringDecoder queryDecoder = new QueryStringDecoder(req.getUri()); File resource...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testBench1() throws Exception { if (System.getProperty("skipBenchmark") != null) { System.out.println(":: skipping naive benchmarks..."); return; } System.out.println(":: running naive benchmarks, set -DskipBenchmark to skip"); String expr = "foo...
#vulnerable code @Test public void testBench1() throws Exception { if (System.getProperty("skipBenchmark") != null && System.getProperty("skipBenchmark").equals("true")) { System.out.println(":: skipping naive benchmarks..."); return; } System.out.println(":: running naive ben...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void canUpsertWithWriteConcern() throws Exception { /* when */ WriteResult writeResult = collection.update("{}").upsert().concern(WriteConcern.SAFE).with("{$set:{name:'John'}}"); /* then */ People john = collection.findOne("{...
#vulnerable code @Test public void canUpsertWithWriteConcern() throws Exception { WriteConcern writeConcern = spy(WriteConcern.SAFE); /* when */ WriteResult writeResult = collection.upsert("{}", "{$set:{name:'John'}}", writeConcern); /* then */ ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void canModifyAlreadySavedEntity() throws Exception { /* given */ People john = new People("John", "21 Jump Street"); collection.save(john); john.setAddress("new address"); /* when */ collection.save(john); ...
#vulnerable code @Test public void canModifyAlreadySavedEntity() throws Exception { /* given */ String idAsString = collection.save(new People("John", "21 Jump Street")); ObjectId id = new ObjectId(idAsString); People people = collection.findOne(id).a...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void canFindOne() throws Exception { /* given */ String id = collection.save(new People("John", new Coordinate(1, 1))); /* when */ People result = collection.findOne("{name:#}", "John").as(People.class); /* then */ ...
#vulnerable code @Test public void canFindOne() throws Exception { /* given */ String id = collection.save(this.people); /* when */ People people = collection.findOne("{name:#}", "John").as(People.class); /* then */ assertThat(people...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void canModifyAlreadySavedEntity() throws Exception { /* given */ People john = new People("John", "21 Jump Street"); collection.save(john); john.setAddress("new address"); /* when */ collection.save(john); ...
#vulnerable code @Test public void canModifyAlreadySavedEntity() throws Exception { /* given */ String idAsString = collection.save(new People("John", "21 Jump Street")); ObjectId id = new ObjectId(idAsString); People people = collection.findOne(id).a...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test //https://groups.google.com/forum/?fromgroups#!topic/jongo-user/p9CEKnkKX9Q public void canUpdateIntoAnArray() throws Exception { collection.insert("{friends:[{name:'Robert'},{name:'Peter'}]}"); collection.update("{ 'friends.name' : 'Peter' }")...
#vulnerable code @Test //https://groups.google.com/forum/?fromgroups#!topic/jongo-user/p9CEKnkKX9Q public void canUpdateIntoAnArray() throws Exception { collection.insert("{friends:[{name:'Robert'},{name:'Peter'}]}"); collection.update("{ 'friends.name' : 'Pete...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void canFindOneWithObjectId() throws Exception { /* given */ Friend john = new Friend("John", "22 Wall Street Avenue"); collection.save(john); Friend foundFriend = collection.findOne(john.getId()).as(Friend.class); /*...
#vulnerable code @Test public void canFindOneWithObjectId() throws Exception { /* given */ People john = new People("John", "22 Wall Street Avenue"); collection.save(john); People foundPeople = collection.findOne(john.getId()).as(People.class); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void canFindOneWithEmptyQuery() throws Exception { /* given */ collection.save(new Friend("John", "22 Wall Street Avenue")); /* when */ Friend friend = collection.findOne().as(Friend.class); /* then */ assertT...
#vulnerable code @Test public void canFindOneWithEmptyQuery() throws Exception { /* given */ collection.save(new People("John", "22 Wall Street Avenue")); /* when */ People people = collection.findOne().as(People.class); /* then */ a...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void canSaveAnObjectWithAnObjectId() throws Exception { People john = new People(new ObjectId("47cc67093475061e3d95369d"), "John"); collection.save(john); People result = collection.findOne(new ObjectId("47cc67093475061e3d95369d"))....
#vulnerable code @Test public void canSaveAnObjectWithAnObjectId() throws Exception { People john = new People(new ObjectId("47cc67093475061e3d95369d"), "John"); String id = collection.save(john); People result = collection.findOne(new ObjectId(id)).as(Peo...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void canFindOne() throws Exception { /* given */ collection.save(new Friend("John", "22 Wall Street Avenue")); /* when */ Friend friend = collection.findOne("{name:'John'}").as(Friend.class); /* then */ assert...
#vulnerable code @Test public void canFindOne() throws Exception { /* given */ collection.save(new People("John", "22 Wall Street Avenue")); /* when */ People people = collection.findOne("{name:'John'}").as(People.class); /* then */ ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void canUpsert() throws Exception { /* when */ WriteResult writeResult = collection.update("{}").upsert().with("{$set:{name:'John'}}"); /* then */ People john = collection.findOne("{name:'John'}").as(People.class); as...
#vulnerable code @Test public void canUpsert() throws Exception { /* when */ WriteResult writeResult = collection.upsert("{}", "{$set:{name:'John'}}"); /* then */ People john = collection.findOne("{name:'John'}").as(People.class); assertThat...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public String readFile(final String path) throws FileNotFoundException { try (Scanner scanner = new java.util.Scanner(new java.io.File(this.fileBase, path), "UTF-8")) { return scanner.useDelimiter("\\Z").next().toString(); } }
#vulnerable code @Override public String readFile(final String path) throws FileNotFoundException { return new java.util.Scanner(new java.io.File(this.fileBase, path), "UTF-8").useDelimiter("\\Z").next().toString(); } #location 3 ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void createJarFromClassPathResources(final FileOutputStream fos, final String location) throws IOException { final Manifest m = new Manifest(); m.clear(); final Attributes global = m.getMainAttributes(); if (global.getValue(Attributes.Name.MANIFES...
#vulnerable code private void createJarFromClassPathResources(final FileOutputStream fos, final String location) throws IOException { final Manifest m = new Manifest(); m.clear(); final Attributes global = m.getMainAttributes(); if (global.getValue(Attributes.Name.M...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static byte[] classAsBytes(final String className) throws ClassNotFoundException { final URL resource = ClassUtils.class.getClassLoader().getResource( convertClassNameToFileName(className)); try(BufferedInputStream stream = new BufferedInputStream( ...
#vulnerable code public static byte[] classAsBytes(final String className) throws ClassNotFoundException { try { final URL resource = ClassUtils.class.getClassLoader().getResource( convertClassNameToFileName(className)); final BufferedInputStream stream = n...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public Tokenizer create(Reader reader) { Seg seg_method=null; if(seg_type.equals("max_word")){ seg_method = new MaxWordSeg(dic); }else if(seg_type.equals("complex")){ seg_method = new ComplexSeg(dic); }else...
#vulnerable code @Override public Tokenizer create(Reader reader) { logger.info(seg_type); Seg seg_method=null; if(seg_type.equals("max_word")){ seg_method = new MaxWordSeg(dic); }else if(seg_type.equals("complex")){ seg_method...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public boolean register(HttpServletResponse response , String userName , String passWord , String salt) { MiaoshaUser miaoShaUser = new MiaoshaUser(); miaoShaUser.setNickname(userName); String DBPassWord = MD5Utils.formPassToDBPass(passWord , salt); ...
#vulnerable code public boolean register(HttpServletResponse response , String userName , String passWord , String salt) { MiaoshaUser miaoShaUser = new MiaoshaUser(); miaoShaUser.setNickname(userName); String DBPassWord = MD5Utils.formPassToDBPass(passWord , s...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static EntityManager createEntityManager() { init(false); return PersistUtilHelper.getEntityManager(); }
#vulnerable code public static EntityManager createEntityManager() { init(false); return PersistUtilHelper.getEntityManager(); // return entityManagerFactory.createEntityManager(); } #location 2 #vulne...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static EntityManager createEntityManager() { init(false); return PersistUtilHelper.getEntityManager(); }
#vulnerable code public static EntityManager createEntityManager() { init(false); return PersistUtilHelper.getEntityManager(); // return entityManagerFactory.createEntityManager(); } #location 3 #vulne...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected void initialize(boolean strict) { try { activator = DOMHelper.getElementByAttribute("data-activates", getId()); if (!isFixed()) { String style = activator.getAttribute("style"); if (alwaysShowActivator)...
#vulnerable code protected void initialize(boolean strict) { try { activator = DOMHelper.getElementByAttribute("data-activates", getId()); if (alwaysShowActivator || !isFixed()) { String style = activator.getAttribute("style"); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void add(Widget child) { super.add(wrap(child)); }
#vulnerable code @Override public void add(Widget child) { if(child instanceof MaterialImage) { child.getElement().getStyle().setProperty("border", "1px solid #e9e9e9"); child.getElement().getStyle().setProperty("textAlign", "center"); } ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void setValue(Integer value, boolean fireEvents) { try { checkRangeValue(value); setIntToRangeElement(VALUE, value); } catch(Exception e) { getLogger().log(Level.SEVERE, e.getMessage()); } ...
#vulnerable code @Override public void setValue(Integer value, boolean fireEvents) { if (value == null) { GWT.log("Value must be null", new RuntimeException()); return; } if (value < getMin()) { GWT.log("Value must not be l...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected void load(boolean strict) { try { activator = DOMHelper.getElementByAttribute("data-activates", getId()); MaterialWidget navMenu = getNavMenu(); if (navMenu != null) { navMenu.setShowOn(ShowOn.SHOW_ON_MED_...
#vulnerable code protected void load(boolean strict) { try { activator = DOMHelper.getElementByAttribute("data-activates", getId()); getNavMenu().setShowOn(ShowOn.SHOW_ON_MED_DOWN); if (alwaysShowActivator && !getTypeMixin().getStyle().equals(...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected void applyOverlayType() { setShowOnAttach(false); if (overlayOpeningHandler == null) { overlayOpeningHandler = addOpeningHandler(event -> { Scheduler.get().scheduleDeferred(() -> $("#sidenav-overlay").css("visibility", "vi...
#vulnerable code protected void applyOverlayType() { setShowOnAttach(false); getNavMenu().setShowOn(ShowOn.SHOW_ON_LARGE); if (overlayOpeningHandler == null) { overlayOpeningHandler = addOpeningHandler(event -> { Scheduler.get().schedu...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected void load(boolean strict) { try { activator = DOMHelper.getElementByAttribute("data-activates", getId()); MaterialWidget navMenu = getNavMenu(); if (navMenu != null) { navMenu.setShowOn(ShowOn.SHOW_ON_MED_...
#vulnerable code protected void load(boolean strict) { try { activator = DOMHelper.getElementByAttribute("data-activates", getId()); getNavMenu().setShowOn(ShowOn.SHOW_ON_MED_DOWN); if (alwaysShowActivator && !getTypeMixin().getStyle().equals(...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void add(Widget child) { super.add(wrap(child)); }
#vulnerable code @Override public void add(Widget child) { if(child instanceof MaterialImage) { child.getElement().getStyle().setProperty("border", "1px solid #e9e9e9"); child.getElement().getStyle().setProperty("textAlign", "center"); } ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void doRender(RunTemplate runTemplate, NumbericRenderData numbericData, XWPFTemplate template) throws Exception { NiceXWPFDocument doc = template.getXWPFDocument(); XWPFRun run = runTemplate.getRun(); List<TextRenderDat...
#vulnerable code @Override public void doRender(RunTemplate runTemplate, NumbericRenderData numbericData, XWPFTemplate template) throws Exception { NiceXWPFDocument doc = template.getXWPFDocument(); XWPFRun run = runTemplate.getRun(); List<TextRen...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void writeToFile(String path) throws IOException { FileOutputStream out = null; try { out = new FileOutputStream(path); this.write(out); out.flush(); } finally { PoitlIOUtils.closeQuietlyMu...
#vulnerable code public void writeToFile(String path) throws IOException { FileOutputStream out = new FileOutputStream(path); this.write(out); this.close(); out.flush(); out.close(); } #location 7 ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static byte[] getUrlByteArray(String urlPath) { try { return toByteArray(getUrlPictureStream(urlPath)); } catch (IOException e) { logger.error("getUrlPictureStream error,{},{}", urlPath, e); } return null; }
#vulnerable code public static byte[] getUrlByteArray(String urlPath) { return toByteArray(getUrlPictureStream(urlPath)); } #location 2 #vulnerability type RESOURCE_LEAK
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override protected void afterRender(RenderContext context) { clearPlaceholder(context, true); // IRunBody parent = run.getParent(); // if (parent instanceof XWPFParagraph) { // ((XWPFParagraph) parent).removeRun(((RunTemplate) context.get...
#vulnerable code @Override protected void afterRender(RenderContext context) { XWPFRun run = ((RunTemplate) context.getEleTemplate()).getRun(); clearPlaceholder(context); IRunBody parent = run.getParent(); if (parent instanceof XWPFParagraph) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void visit(InlineIterableTemplate iterableTemplate) { logger.info("Process InlineIterableTemplate:{}", iterableTemplate); super.visit((IterableTemplate) iterableTemplate); }
#vulnerable code @Override public void visit(InlineIterableTemplate iterableTemplate) { logger.info("Process InlineIterableTemplate:{}", iterableTemplate); BodyContainer bodyContainer = BodyContainerFactory.getBodyContainer(iterableTemplate); Object compute...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void visit(InlineIterableTemplate iterableTemplate) { logger.info("Process InlineIterableTemplate:{}", iterableTemplate); super.visit((IterableTemplate) iterableTemplate); }
#vulnerable code @Override public void visit(InlineIterableTemplate iterableTemplate) { logger.info("Process InlineIterableTemplate:{}", iterableTemplate); BodyContainer bodyContainer = BodyContainerFactory.getBodyContainer(iterableTemplate); Object compute...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void doRender(ChartTemplate eleTemplate, ChartMultiSeriesRenderData data, XWPFTemplate template) throws Exception { XWPFChart chart = eleTemplate.getChart(); List<XDDFChartData> chartSeries = chart.getChartSeries(); val...
#vulnerable code @Override public void doRender(ChartTemplate eleTemplate, ChartMultiSeriesRenderData data, XWPFTemplate template) throws Exception { if (null == data) return; XWPFChart chart = eleTemplate.getChart(); List<XDDFChartData> chartSeri...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private List<NiceXWPFDocument> getMergedDocxs(DocxRenderData data, Configure configure) throws IOException { List<NiceXWPFDocument> docs = new ArrayList<NiceXWPFDocument>(); byte[] docx = data.getDocx(); List<?> dataList = data.getDataList(); i...
#vulnerable code private List<NiceXWPFDocument> getMergedDocxs(DocxRenderData data, Configure configure) { List<NiceXWPFDocument> docs = new ArrayList<NiceXWPFDocument>(); File docx = data.getDocx(); List<?> dataList = data.getDataList(); if (null == data...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void shouldAddHeader() throws IOException { driver.addExpectation(onRequestTo("/") .withHeader("X-Trace-ID", "16c38974-7530-11e5-bb35-10ddb1ee7671") .withHeader("X-Request-ID", "2e7a3324-7530-11e5-ad30-1...
#vulnerable code @Test public void shouldAddHeader() throws IOException { driver.addExpectation(onRequestTo("/") .withHeader("X-Trace-ID", "16c38974-7530-11e5-bb35-10ddb1ee7671") .withHeader("X-Request-ID", "2e7a3324-7530-11e5-...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test void jdk() throws IOException, ScriptException { String script = new String(Files.readAllBytes(new File("../dist/bundle.js").toPath())); ScriptEngine js = new ScriptEngineManager().getEngineByExtension("js"); //js.eval(script); V8 v8 ...
#vulnerable code @Test void jdk() { Graphviz.useEngine(new GraphvizJdkEngine()); assertThat(Graphviz.fromString("graph g {a--b}").render(SVG_STANDALONE).toString(), startsWith(START1_7)); } #location 3 #vu...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test void ex8() throws IOException { //## image Graphviz g = Graphviz.fromGraph(graph() .with(node(" ").with(Size.std().margin(.8, .7), Image.of("graphviz.png")))); g.basedir(new File("example")).render(Format.PNG).toFile(new File(...
#vulnerable code @Test void ex8() throws IOException { //## image Graphviz.useEngine(new GraphvizV8Engine()); Graphviz g = Graphviz.fromGraph(graph() .with(node(" ").with(Size.std().margin(.8, .7), Image.of("graphviz.png")))); g.basedi...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test void jdk() { Graphviz.useEngine(new GraphvizJdkEngine()); assertThat(Graphviz.fromString("graph g {a--b}").render(SVG_STANDALONE).toString(), startsWith(START1_7)); }
#vulnerable code @Test void jdk() throws IOException, ScriptException { String script = new String(Files.readAllBytes(new File("../dist/bundle.js").toPath())); ScriptEngine js = new ScriptEngineManager().getEngineByExtension("js"); //js.eval(script); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test void cmdLineOutputDotFile() throws IOException, InterruptedException { final File dotOutputFolder = new File(temp, "out"); dotOutputFolder.mkdir(); final String dotOutputName = "test123"; // Configure engine to output the dotFile to ...
#vulnerable code @Test void cmdLineOutputDotFile() throws IOException, InterruptedException { final File dotFile = setUpFakeDotFile(); final CommandLineExecutor cmdExecutor = setUpFakeStubCommandExecutor(); final String envPath = dotFile.getParent(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static void releaseEngine() { synchronized (Graphviz.class) { if (engine != null) { doReleaseEngine(engine); } if (engineQueue != null) { for (final GraphvizEngine engine : engineQueue) { ...
#vulnerable code public static void releaseEngine() { if (engine != null) { try { engine.close(); } catch (Exception e) { throw new GraphvizException("Problem closing engine", e); } } engine = nu...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static void useDefaultEngines() { useEngine(AVAILABLE_ENGINES); }
#vulnerable code public static void useDefaultEngines() { useEngine(new GraphvizCmdLineEngine(), new GraphvizV8Engine(), new GraphvizServerEngine(), new GraphvizJdkEngine()); } #location 2 #vulnerabili...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static void releaseEngine() { synchronized (Graphviz.class) { if (engine != null) { doReleaseEngine(engine); } if (engineQueue != null) { for (final GraphvizEngine engine : engineQueue) { ...
#vulnerable code public static void releaseEngine() { if (engine != null) { try { engine.close(); } catch (Exception e) { throw new GraphvizException("Problem closing engine", e); } } engine = nu...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static void useDefaultEngines() { useEngine(AVAILABLE_ENGINES); }
#vulnerable code public static void useDefaultEngines() { useEngine(new GraphvizCmdLineEngine(), new GraphvizV8Engine(), new GraphvizServerEngine(), new GraphvizJdkEngine()); } #location 2 #vulnerabili...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static void start(List<GraphvizEngine> engines) throws IOException { final String executable = SystemUtils.executableName("java"); final List<String> cmd = new ArrayList<>(Arrays.asList( System.getProperty("java.home") + "/bin/" + execut...
#vulnerable code public static void start(List<GraphvizEngine> engines) throws IOException { final boolean windows = System.getProperty("os.name").contains("windows"); final String executable = windows ? "java.exe" : "java"; final List<String> cmd = new ArrayList...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public Page download(Request request, Task task) { Site site = null; if (task != null) { site = task.getSite(); } Set<Integer> acceptStatCode; String charset = null; Map<String, String> headers = null; ...
#vulnerable code @Override public Page download(Request request, Task task) { Site site = null; if (task != null) { site = task.getSite(); } int retryTimes = 0; Set<Integer> acceptStatCode; String charset = null; Ma...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected void checkComponent() { if (downloader == null) { this.downloader = new HttpClientDownloader(); } if (pipelines.isEmpty()) { pipelines.add(new ConsolePipeline()); } downloader.setThread(threadNum); ...
#vulnerable code protected void checkComponent() { if (downloader == null) { this.downloader = new HttpClientDownloader(); } } #location 2 #vulnerability type THREAD_SAFETY_VIOLATION
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void run() { if (!stat.compareAndSet(STAT_INIT, STAT_RUNNING)) { throw new IllegalStateException("Spider is already running!"); } checkComponent(); if (startUrls != null) { for (String startUrl : sta...
#vulnerable code @Override public void run() { if (!stat.compareAndSet(STAT_INIT, STAT_RUNNING)) { throw new IllegalStateException("Spider is already running!"); } checkComponent(); if (startUrls != null) { for (String startUrl...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Ignore @Test public void testCookie() { Site site = Site.me().setDomain("www.diandian.com").addCookie("t", "yct7q7e6v319wpg4cpxqduu5m77lcgix"); HttpClientDownloader httpClientDownloader = new HttpClientDownloader(); Page download = httpClientD...
#vulnerable code @Ignore @Test public void testCookie() { Site site = Site.me().setDomain("www.diandian.com").addCookie("t", "yct7q7e6v319wpg4cpxqduu5m77lcgix"); HttpClientDownloader httpClientDownloader = new HttpClientDownloader(); Page download = httpC...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public Spider thread(int threadNum) { checkIfRunning(); this.threadNum = threadNum; if (threadNum <= 0) { throw new IllegalArgumentException("threadNum should be more than one!"); } if (threadNum == 1) { return t...
#vulnerable code public Spider thread(int threadNum) { checkIfRunning(); this.threadNum = threadNum; if (threadNum <= 0) { throw new IllegalArgumentException("threadNum should be more than one!"); } if (threadNum == 1) { re...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void readCursorFile() throws IOException { BufferedReader fileCursorReader = null; try { fileCursorReader = new BufferedReader(new FileReader(getFileName(fileCursor))); String line; //read the last number wh...
#vulnerable code private void readCursorFile() throws IOException { BufferedReader fileCursorReader = null; try { new BufferedReader(new FileReader(getFileName(fileCursor))); String line; //read the last number while ((line...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void readCursorFile() throws IOException { BufferedReader fileCursorReader = null; try { fileCursorReader = new BufferedReader(new FileReader(getFileName(fileCursor))); String line; //read the last number wh...
#vulnerable code private void readCursorFile() throws IOException { BufferedReader fileCursorReader = null; try { new BufferedReader(new FileReader(getFileName(fileCursor))); String line; //read the last number while ((line...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testGetHtmlCharset() throws Exception { HttpServer server = httpserver(12306); server.get(by(uri("/header"))).response(header("Content-Type", "text/html; charset=gbk")); server.get(by(uri("/meta4"))).response(with(text("<html>\n" ...
#vulnerable code @Test public void testGetHtmlCharset() throws IOException { HttpClientDownloader downloader = new HttpClientDownloader(); Site site = Site.me(); CloseableHttpClient httpClient = new HttpClientGenerator().getClient(site); // encoding i...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected void checkComponent() { if (downloader == null) { this.downloader = new HttpClientDownloader(); } if (pipelines.isEmpty()) { pipelines.add(new ConsolePipeline()); } downloader.setThread(threadNum); ...
#vulnerable code protected void checkComponent() { if (downloader == null) { this.downloader = new HttpClientDownloader(); } } #location 3 #vulnerability type THREAD_SAFETY_VIOLATION
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void run() { if (!stat.compareAndSet(STAT_INIT, STAT_RUNNING) && !stat.compareAndSet(STAT_STOPPED, STAT_RUNNING)) { throw new IllegalStateException("Spider is already running!"); } checkComponent(); ...
#vulnerable code @Override public void run() { if (!stat.compareAndSet(STAT_INIT, STAT_RUNNING) && !stat.compareAndSet(STAT_STOPPED, STAT_RUNNING)) { throw new IllegalStateException("Spider is already running!"); } checkComponent()...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void run() { checkRunningStat(); initComponent(); logger.info("Spider " + getUUID() + " started!"); final AtomicInteger threadAlive = new AtomicInteger(0); while (!Thread.currentThread().isInterrupted() && stat.get(...
#vulnerable code @Override public void run() { checkRunningStat(); initComponent(); logger.info("Spider " + getUUID() + " started!"); final AtomicInteger threadAlive = new AtomicInteger(0); while (!Thread.currentThread().isInterrupted() && sta...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testRemovePadding() throws Exception { String name = new Json(text).removePadding("callback").jsonPath("$.name").get(); assertThat(name).isEqualTo("json"); }
#vulnerable code @Test public void testRemovePadding() throws Exception { String name = new Json(text).removePadding("callback").jsonPath("$.name").get(); assertThat(name).isEqualTo("json"); Page page = null; page.getJson().jsonPath("$.name").get(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public Page download(Request request, Task task) { Site site = null; if (task != null) { site = task.getSite(); } int retryTimes = 0; Set<Integer> acceptStatCode; String charset = null; Map<Stri...
#vulnerable code @Override public Page download(Request request, Task task) { Site site = null; if (task != null) { site = task.getSite(); } int retryTimes = 0; Set<Integer> acceptStatCode; String charset = null; Ma...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void run() { checkRunningStat(); initComponent(); logger.info("Spider " + getUUID() + " started!"); while (!Thread.currentThread().isInterrupted() && stat.get() == STAT_RUNNING) { Request request = scheduler.pol...
#vulnerable code @Override public void run() { checkRunningStat(); initComponent(); logger.info("Spider " + getUUID() + " started!"); while (!Thread.currentThread().isInterrupted() && stat.get() == STAT_RUNNING) { Request request = schedul...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public Page download(Request request, Task task) { Site site = null; if (task != null) { site = task.getSite(); } Set<Integer> acceptStatCode; String charset = null; Map<String, String> headers = null; ...
#vulnerable code @Override public Page download(Request request, Task task) { Site site = null; if (task != null) { site = task.getSite(); } int retryTimes = 0; Set<Integer> acceptStatCode; String charset = null; Ma...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void run() { checkRunningStat(); initComponent(); logger.info("Spider " + getUUID() + " started!"); final AtomicInteger threadAlive = new AtomicInteger(0); while (!Thread.currentThread().isInterrupted() && stat.get(...
#vulnerable code @Override public void run() { checkRunningStat(); initComponent(); logger.info("Spider " + getUUID() + " started!"); final AtomicInteger threadAlive = new AtomicInteger(0); while (!Thread.currentThread().isInterrupted() && sta...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public Spider thread(int threadNum) { checkIfNotRunning(); this.threadNum = threadNum; if (threadNum <= 0) { throw new IllegalArgumentException("threadNum should be more than one!"); } if (threadNum == 1) { retur...
#vulnerable code public Spider thread(int threadNum) { checkIfNotRunning(); if (threadNum <= 0) { throw new IllegalArgumentException("threadNum should be more than one!"); } if (downloader==null || downloader instanceof HttpClientDownloader){ ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void setThread(int thread) { poolSize = thread; }
#vulnerable code @Override public void setThread(int thread) { poolSize = thread; httpClientPool = new HttpClientPool(thread); } #location 4 #vulnerability type THREAD_SAFETY_VIOLATION
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override protected void pushWhenNoDuplicate(Request request, Task task) { /* if (!inited.get()) { init(task); }*/ queue.add(request); fileUrlWriter.println(request.getUrl()); }
#vulnerable code @Override protected void pushWhenNoDuplicate(Request request, Task task) { if (!inited.get()) { init(task); } queue.add(request); fileUrlWriter.println(request.getUrl()); } #location 4 ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void run() { checkRunningStat(); initComponent(); logger.info("Spider " + getUUID() + " started!"); final AtomicInteger threadAlive = new AtomicInteger(0); while (!Thread.currentThread().isInterrupted() && stat.get(...
#vulnerable code @Override public void run() { checkRunningStat(); initComponent(); logger.info("Spider " + getUUID() + " started!"); final AtomicInteger threadAlive = new AtomicInteger(0); while (!Thread.currentThread().isInterrupted() && sta...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void setThread(int thread) { httpClientGenerator.setPoolSize(thread); }
#vulnerable code @Override public void setThread(int thread) { poolSize = thread; } #location 3 #vulnerability type THREAD_SAFETY_VIOLATION
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public Page download(Request request, Task task) { Site site = null; if (task != null) { site = task.getSite(); } Set<Integer> acceptStatCode; String charset = null; Map<String, String> headers = null; ...
#vulnerable code @Override public Page download(Request request, Task task) { Site site = null; if (task != null) { site = task.getSite(); } Set<Integer> acceptStatCode; String charset = null; Map<String, String> headers = ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void run() { checkRunningStat(); initComponent(); logger.info("Spider " + getUUID() + " started!"); final AtomicInteger threadAlive = new AtomicInteger(0); while (!Thread.currentThread().isInterrupted() && stat.get(...
#vulnerable code @Override public void run() { checkRunningStat(); initComponent(); logger.info("Spider " + getUUID() + " started!"); final AtomicInteger threadAlive = new AtomicInteger(0); while (!Thread.currentThread().isInterrupted() && sta...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void run() { if (!stat.compareAndSet(STAT_INIT, STAT_RUNNING) && !stat.compareAndSet(STAT_STOPPED, STAT_RUNNING)) { throw new IllegalStateException("Spider is already running!"); } checkComponent(); ...
#vulnerable code @Override public void run() { if (!stat.compareAndSet(STAT_INIT, STAT_RUNNING) && !stat.compareAndSet(STAT_STOPPED, STAT_RUNNING)) { throw new IllegalStateException("Spider is already running!"); } checkComponent()...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void readCursorFile() throws IOException { BufferedReader fileCursorReader = null; try { new BufferedReader(new FileReader(getFileName(fileCursor))); String line; //read the last number while ((line = fil...
#vulnerable code private void readCursorFile() throws IOException { BufferedReader fileCursorReader = new BufferedReader(new FileReader(getFileName(fileCursor))); String line; //read the last number while ((line = fileCursorReader.readLine()) != null) { ...
Below is the vulnerable code, please generate the patch based on the following information.