input
stringlengths
205
73.3k
output
stringlengths
64
73.2k
instruction
stringclasses
1 value
#vulnerable code public void handle(Invocation inv) { try { if (inv.operation == OP_RESPONSE) { handleResponse(inv); } else if (inv.operation == OP_BIND) { Address addressEndPoint = (Address) inv.getValueObject(); ConnectionManager.get().bind(addressEndPoint, inv.conn);...
#fixed code public void handle(Invocation inv) { try { if (inv.operation == OP_RESPONSE) { handleResponse(inv); } else if (inv.operation == OP_REMOTELY_PROCESS_AND_RESPONSE) { Data data = inv.doTake(inv.data); RemotelyProcessable rp = (RemotelyProcessable) ThreadContext....
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public V get(Object key) { // MapGetCall mGet = new MapGetCall(); Packet request = createRequestPacket(); request.setOperation(ClusterOperation.CONCURRENT_MAP_GET); request.setKey(Serializer.toByte(key)); Packet response = callAndGetResult(req...
#fixed code public V get(Object key) { return (V)doOp(ClusterOperation.CONCURRENT_MAP_GET, Serializer.toByte(key), null); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void run() { while (running) { Object obj = null; try { lsBuffer.clear(); queue.drainTo(lsBuffer); int size = lsBuffer.size(); if (size > 0) { for (int i = 0; i < size; i++) { obj = lsBuffer.get(i); process(obj); } ...
#fixed code public void run() { while (running) { Object obj = null; try { lsBuffer.clear(); queue.drainTo(lsBuffer); int size = lsBuffer.size(); if (size > 0) { for (int i = 0; i < size; i++) { obj = lsBuffer.get(i); checkHeartbeat(); process...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected Packet callAndGetResult(Packet request) { Call c = createCall(request); synchronized (c) { try { out.enQueue(c); c.wait(); } catch (InterruptedException e) { e.printStackTrace(); } } Packet response = c.getResponse(); re...
#fixed code protected Packet callAndGetResult(Packet request) { Call c = createCall(request); return doCall(c); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void readData(DataInput in) throws IOException { mapPuts.set(in.readLong()); mapGets.set(in.readLong()); mapRemoves.set(in.readLong()); startTime = in.readLong(); endTime = in.readLong(); } ...
#fixed code public void readData(DataInput in) throws IOException { numberOfPuts = in.readLong(); numberOfGets = in.readLong(); numberOfRemoves = in.readLong(); numberOfOtherOperations = in.readLong(); periodStart = in.readLong(); periodEnd...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void run() { boolean readPackets = false; boolean readProcessables = false; while (running) { readPackets = (dequeuePackets() != 0); readProcessables = (dequeueProcessables() != 0); if (!readPackets && !...
#fixed code public void run() { boolean readPackets = false; boolean readProcessables = false; while (running) { readPackets = (dequeuePackets() != 0); readProcessables = (dequeueProcessables() != 0); if (!readPackets && !readPr...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code void migrateBlock(final Block blockInfo) { if (!concurrentMapManager.isBlockInfoValid(blockInfo)) { return; } if (!thisAddress.equals(blockInfo.getOwner())) { throw new RuntimeException(); } if (!blockInfo....
#fixed code void reArrangeBlocks() { if (concurrentMapManager.isMaster()) { Map<Address, Integer> addressBlocks = getCurrentMemberBlocks(); if (addressBlocks.size() == 0) { return; } List<Block> lsBlocksToRedistribut...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code void doPublish(Request req) { Q q = getQ(req.name); if (q.blCurrentPut == null) { q.setCurrentPut(); } int index = q.publish(req); req.longValue = index; req.response = Boolean.TRUE; } ...
#fixed code void syncForDead(Address addressDead) { MemberImpl member = getNextMemberBeforeSync(addressDead, true, 1); if (DEBUG) { log(addressDead + " is dead and its backup was " + member); } Address addressNewOwner = (member == null) ? thisA...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code void migrateBlock(final Block block) { if (!concurrentMapManager.isBlockInfoValid(block)) { return; } if (!thisAddress.equals(block.getOwner())) { throw new RuntimeException(); } if (block.getMigrationAddre...
#fixed code void reArrangeBlocks() { if (concurrentMapManager.isMaster()) { List<MemberImpl> lsMembers = concurrentMapManager.lsMembers; // make sue that all blocks are actually created for (int i = 0; i < BLOCK_COUNT; i++) { Bl...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void writeData(DataOutput out) throws IOException { out.writeLong(mapPuts.get()); out.writeLong(mapGets.get()); out.writeLong(mapRemoves.get()); out.writeLong(startTime); out.writeLong(endTime); } ...
#fixed code public void writeData(DataOutput out) throws IOException { out.writeLong(numberOfPuts); out.writeLong(numberOfGets); out.writeLong(numberOfRemoves); out.writeLong(numberOfOtherOperations); out.writeLong(periodStart); out.writeLo...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void readFrom(DataInputStream dis) throws IOException { System.out.println("Available:" + dis.available()); headerSize = dis.readInt(); keySize = dis.readInt(); valueSize = dis.readInt(); headerInBytes = new byte[headerSize]; dis.read(headerInBytes); ...
#fixed code public void readFrom(DataInputStream dis) throws IOException { headerSize = dis.readInt(); keySize = dis.readInt(); valueSize = dis.readInt(); headerInBytes = new byte[headerSize]; dis.read(headerInBytes); ByteArrayInputStream bis = new ByteArrayInputStream(hea...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code void doAddTopicListener(Request req) { for (MemberImpl member : lsMembers) { if (member.localMember()) { handleListenerRegisterations(true, req.name, req.key, req.caller, true); } else if (!member.getAddress().equals(req.c...
#fixed code void syncForDead(Address addressDead) { MemberImpl member = getNextMemberBeforeSync(addressDead, true, 1); if (DEBUG) { log(addressDead + " is dead and its backup was " + member); } Address addressNewOwner = (member == null) ? thisA...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code void initiateMigration() { for (int i = 0; i < BLOCK_COUNT; i++) { Block block = blocks[i]; if (block == null) { block = concurrentMapManager.getOrCreateBlock(i); block.setOwner(thisAddress); } ...
#fixed code void reArrangeBlocks() { if (concurrentMapManager.isMaster()) { Map<Address, Integer> addressBlocks = getCurrentMemberBlocks(); if (addressBlocks.size() == 0) { return; } List<Block> lsBlocksToRedistribut...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void readFrom(DataInputStream dis) throws IOException { System.out.println("Available:" + dis.available()); headerSize = dis.readInt(); keySize = dis.readInt(); valueSize = dis.readInt(); headerInBytes = new byte[headerSize]; dis.read(headerInBytes); ...
#fixed code public void readFrom(DataInputStream dis) throws IOException { headerSize = dis.readInt(); keySize = dis.readInt(); valueSize = dis.readInt(); headerInBytes = new byte[headerSize]; dis.read(headerInBytes); ByteArrayInputStream bis = new ByteArrayInputStream(hea...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public long getPeriodEnd() { return endTime; } #location 2 #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code public long getPeriodEnd() { return periodEnd; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void process(Object obj) { long processStart = System.nanoTime(); if (obj instanceof Invocation) { Invocation inv = (Invocation) obj; MemberImpl memberFrom = getMember(inv.conn.getEndPoint()); if (memberFrom != null) { memberFrom.didRead(); } ...
#fixed code public void process(Object obj) { long processStart = System.nanoTime(); if (obj instanceof Invocation) { Invocation inv = (Invocation) obj; MemberImpl memberFrom = getMember(inv.conn.getEndPoint()); if (memberFrom != null) { memberFrom.didRead(); } int op...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void describeAsAdditionalInfo_notEmpty() { Correspondence.ExceptionStore exceptions = Correspondence.ExceptionStore.forIterable(); addCompareException(exceptions); assertExpectedFacts( exceptions.describeAsAdditionalInfo().asIterable(), ...
#fixed code @Test public void describeAsAdditionalInfo_notEmpty() { Correspondence.ExceptionStore exceptions = Correspondence.ExceptionStore.forIterable(); addCompareException(exceptions); assertExpectedFacts( exceptions.describeAsAdditionalInfo(), "additional...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void hasField(String fieldName) { if (getSubject() == null) { failWithoutSubject("<null> has a field named <" + fieldName + ">"); } Class<?> clazz = getSubject().getClass(); try { clazz.getField(fieldName); } catch (NoSuchFieldExcept...
#fixed code public void hasField(String fieldName) { if (getSubject() == null) { failureStrategy.fail("Cannot determine a field name from a null object."); return; // not all failures throw exceptions. } check().that(getSubject().getClass()).hasField(fieldName); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void describeAsAdditionalInfo_empty() { Correspondence.ExceptionStore exceptions = Correspondence.ExceptionStore.forIterable(); assertThat(exceptions.describeAsAdditionalInfo().asIterable()).isEmpty(); } #location 4 ...
#fixed code @Test public void describeAsAdditionalInfo_empty() { Correspondence.ExceptionStore exceptions = Correspondence.ExceptionStore.forIterable(); assertThat(exceptions.describeAsAdditionalInfo()).isEmpty(); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public String getConceptNetUrl() { String urlFromConfigOrDefault = getConfiguration().getSettingValueFor(CONFIG_KEY_URL).toString(); return urlFromConfigOrDefault == null ? DEFAULT_CONCEPTNET_URL : urlFromConfigOrDefault;...
#fixed code public String getConceptNetUrl() { String urlFromConfigOrDefault = (String)getConfiguration().getSettingValueFor(CONFIG_KEY_URL); return urlFromConfigOrDefault == null ? DEFAULT_CONCEPTNET_URL : urlFromConfigOrDefault; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public SingleResult process(TextRankRequest request) { TextRank textrank = new TextRank(getDatabase(), getNLPManager().getConfiguration()); if (request.getStopWords() != null && !request.getStopWords().isEmpty()) { textrank...
#fixed code public SingleResult process(TextRankRequest request) { TextRank textrank = new TextRank(getDatabase(), getNLPManager().getConfiguration()); if (request.getStopWords() != null && !request.getStopWords().isEmpty()) { textrank.setSt...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Map<Long, Map<Long, CoOccurrenceItem>> createCooccurrences(Node annotatedText) { Map<String, Object> params = new HashMap<>(); params.put("id", annotatedText.getId()); String query; if (respectSentences) { query = COOCC...
#fixed code public Map<Long, Map<Long, CoOccurrenceItem>> createCooccurrences(Node annotatedText) { Map<String, Object> params = new HashMap<>(); params.put("id", annotatedText.getId()); String query; if (respectSentences) { query = COOCCURRENC...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private Map<Long, Float> createFeatureMapWithCN5New(long firstNode) throws QueryExecutionException { Map<String, Object> params = new HashMap<>(); params.put("id", firstNode); Result res = database.execute("MATCH (doc:AnnotatedText)\n" ...
#fixed code private Map<Long, Float> createFeatureMapWithCN5New(long firstNode) throws QueryExecutionException { Map<String, Object> params = new HashMap<>(); params.put("id", firstNode); Result res = database.execute(DEFAULT_VECTOR_QUERY_WITH_CONCEPT, params); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public SingleResult process(TextRankRequest request) { TextRank.Builder textrankBuilder = new TextRank.Builder(getDatabase(), getNLPManager().getConfiguration()); if (request.getStopWords() != null && !request.getStopWords().isEmpty()) {...
#fixed code public SingleResult process(TextRankRequest request) { TextRankResult result = compute(request); TextRankPersister persister = new TextRankPersister(Label.label(request.getKeywordLabel())); persister.peristKeywords(result.getResult(), request.getNode()...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public boolean evaluate(Node annotatedText, int iter, double damp, double threshold) { Map<Long, Map<Long, CoOccurrenceItem>> coOccurrence = createCooccurrences(annotatedText); PageRank pageRank = new PageRank(database); if (useTfIdfWeights) { ...
#fixed code public boolean evaluate(Node annotatedText, int iter, double damp, double threshold) { Map<Long, Map<Long, CoOccurrenceItem>> coOccurrence = createCooccurrences(annotatedText); PageRank pageRank = new PageRank(database); if (useTfIdfWeights) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public SingleResult process(PageRankRequest request) { String nodeType = request.getNodeType(); String relType = request.getRelationshipType(); String relWeight = request.getRelationshipWeight(); int iter = request.getIteration().intValue...
#fixed code public SingleResult process(PageRankRequest request) { String query = request.getQuery(); int iter = request.getIteration().intValue(); double damp = request.getDamp(); double threshold = request.getThreshold(); boolean respectDirection...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Tag annotateTag(String text, String language) { PipelineSpecification spec = getDefaultPipeline(language); TextProcessor processor = getTextProcessor(spec.getTextProcessor()); return processor.annotateTag(text, spec); } ...
#fixed code public Tag annotateTag(String text, String language) { PipelineSpecification spec = getDefaultPipeline(language); if (spec == null) { LOG.warn("No default annotator for language: " + language); return null; } TextProcess...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void initializePipelineWithoutNEs() { //System.out.println(" >>> default processor: " + NLPManager.getInstance().getTextProcessorsManager().getDefaultProcessor().getAlias()); Map<String, Object> params = new HashMap<>(); params.put("token...
#fixed code private void initializePipelineWithoutNEs() { if (!NLPManager.getInstance().hasPipeline(PIPELINE_WITHOUT_NER)) { Map<String, Object> params = new HashMap<>(); params.put("tokenize", true); params.put("ner", false); Strin...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public String getDefaultModelWorkdir() { String p = configuration.getSettingValueFor(SettingsConstants.DEFAULT_MODEL_WORKDIR).toString(); if (p == null) { throw new RuntimeException("No default model wordking directory set in configuration");...
#fixed code public String getDefaultModelWorkdir() { Object p = configuration.getSettingValueFor(SettingsConstants.DEFAULT_MODEL_WORKDIR); if (p == null) { return getRawConfig().get(IMPORT_DIR_CONF_KEY); } return p.toString(); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Procedure(name = "ga.nlp.parser.powerpoint") public Stream<Page> parsePowerpoint(@Name("file") String filename, @Name(value = "filterPatterns", defaultValue = "") List<String> filterPatterns) { PowerpointParser parser = (PowerpointParser) getNLPManager().ge...
#fixed code @Procedure(name = "ga.nlp.parser.powerpoint") public Stream<Page> parsePowerpoint(@Name("file") String filename, @Name(value = "filterPatterns", defaultValue = "") List<String> filterPatterns) { PowerpointParser parser = (PowerpointParser) getNLPManager().getExten...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private Map<String, Keyword> checkNextKeyword(long tagId, KeywordExtractedItem keywordOccurrence, Map<Long, Map<Long, CoOccurrenceItem>> coOccurrences, Map<Long, KeywordExtractedItem> keywords) { Map<String, Keyword> results = new HashMap<>(); if (!coOcc...
#fixed code private Map<String, Keyword> checkNextKeyword(long tagId, KeywordExtractedItem keywordOccurrence, Map<Long, Map<Long, CoOccurrenceItem>> coOccurrences, Map<Long, KeywordExtractedItem> keywords) { Map<String, Keyword> results = new HashMap<>(); if (!coOccurrenc...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Procedure(name = "ga.nlp.parser.pdf") public Stream<Page> parsePdf(@Name("file") String filename, @Name(value = "filterPatterns", defaultValue = "") List<String> filterPatterns) { TikaPDFParser parser = (TikaPDFParser) getNLPManager().getExtension(TikaPDFPa...
#fixed code @Procedure(name = "ga.nlp.parser.pdf") public Stream<Page> parsePdf(@Name("file") String filename, @Name(value = "filterPatterns", defaultValue = "") List<String> filterPatterns) { TikaPDFParser parser = (TikaPDFParser) getNLPManager().getExtension(TikaPDFParser.c...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private Map<Long, Float> createFeatureMapWithCN5New(long firstNode) throws QueryExecutionException { Map<String, Object> params = new HashMap<>(); params.put("id", firstNode); Result res = database.execute("MATCH (doc:AnnotatedText)\n" ...
#fixed code private Map<Long, Float> createFeatureMapWithCN5New(long firstNode) throws QueryExecutionException { Map<String, Object> params = new HashMap<>(); params.put("id", firstNode); Result res = database.execute(DEFAULT_VECTOR_QUERY_WITH_CONCEPT, params); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public boolean handle(LoginPacket packet) { // Check for supported protocol int index = Arrays.binarySearch(DragonProxy.BEDROCK_SUPPORTED_PROTOCOLS, packet.getProtocolVersion()); if (index < 0) { session.getBedrockSessio...
#fixed code @Override public boolean handle(LoginPacket packet) { // Check for supported protocol int index = Arrays.binarySearch(DragonProxy.BEDROCK_SUPPORTED_PROTOCOLS, packet.getProtocolVersion()); if (index < 0) { session.getBedrockSession().di...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static com.nukkitx.nbt.tag.CompoundTag translateItemNBT(CompoundTag tag) { CompoundTagBuilder root = CompoundTagBuilder.builder(); CompoundTagBuilder display = CompoundTagBuilder.builder(); if(tag.contains("name")) { display.s...
#fixed code public static com.nukkitx.nbt.tag.CompoundTag translateItemNBT(CompoundTag tag) { CompoundTagBuilder root = CompoundTagBuilder.builder(); if(!tag.contains("display")) { CompoundTagBuilder display = CompoundTagBuilder.builder(); if (ta...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public boolean handle(LoginPacket packet) { // TODO: move out of here? idk UpstreamSession session = new UpstreamSession(this.session); this.session.setPlayer(session); try { // Get chain data that contains ide...
#fixed code @Override public boolean handle(LoginPacket packet) { // Check for supported protocol int index = Arrays.binarySearch(DragonProxy.BEDROCK_SUPPORTED_PROTOCOLS, packet.getProtocolVersion()); if (index < 0) { upstream.disconnect(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public boolean handle(LoginPacket packet) { // Check for supported protocol int index = Arrays.binarySearch(DragonProxy.BEDROCK_SUPPORTED_PROTOCOLS, packet.getProtocolVersion()); if (index < 0) { session.getBedrockSessio...
#fixed code @Override public boolean handle(LoginPacket packet) { // Check for supported protocol int index = Arrays.binarySearch(DragonProxy.BEDROCK_SUPPORTED_PROTOCOLS, packet.getProtocolVersion()); if (index < 0) { session.getBedrockSession().di...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(String[] args) { log.info("Starting DragonProxy..."); // Check the java version if (Float.parseFloat(System.getProperty("java.class.version")) < 52.0) { log.error("DragonProxy requires Java 8! Current version:...
#fixed code public static void main(String[] args) { log.info("Starting DragonProxy..."); // Check the java version if (Float.parseFloat(System.getProperty("java.class.version")) < 52.0) { log.error("DragonProxy requires Java 8! Current version: " + S...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void initialize() throws Exception { if(!RELEASE) { logger.warn("This is a development build. It may contain bugs. Do not use in production."); } // Create injector, provide elements from the environment and register provider...
#fixed code private void initialize() throws Exception { if(!RELEASE) { logger.warn("This is a development build. It may contain bugs. Do not use in production."); } // Create injector, provide elements from the environment and register providers ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(String... args) throws InterruptedException { Config config = getConfig(args); Dispatcher dispatcher; switch (config.getCommand()) { case INSERT: dispatcher = new InsertDispatcher(config); ...
#fixed code public static void main(String... args) throws InterruptedException { // Manually grok the command argument in order to conditionally apply different options. if (args.length < 1) { System.err.println("Missing command argument."); prin...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public Row<Measurement> next() { if (!hasNext()) throw new NoSuchElementException(); Row<Measurement> output = new Row<>(m_timestamps.next(), m_resource); while (m_current != null) { accumulate(m_current, output.getTi...
#fixed code @Override public Row<Measurement> next() { if (!hasNext()) throw new NoSuchElementException(); Row<Measurement> output = new Row<>(m_timestamps.next(), m_resource); while (m_current != null) { accumulate(m_current, output.getTimestam...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private int go(String[] args) { m_parser.setUsageWidth(80); try { m_parser.parseArgument(args); } catch (CmdLineException e) { System.err.println(e.getMessage()); printUsage(System.err); r...
#fixed code private int go(String[] args) { m_parser.setUsageWidth(80); try { m_parser.parseArgument(args); } catch (CmdLineException e) { System.err.println(e.getMessage()); printUsage(System.err); return ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test(expected = ReflectionException.class) public void shouldFailGetter() { PojoField pojoField = getPrivateStringField(); pojoField.invokeGetter(null); } #location 4 #vulnerability type NULL_DEREFEREN...
#fixed code @Test(expected = ReflectionException.class) public void shouldFailGetter() { PojoField pojoField = getPrivateStringField(); assert pojoField != null; pojoField.invokeGetter(null); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Object doGenerate(final Class<?> type) { PojoClass pojoClass = PojoClassFactory.getPojoClass(type); PojoMethod valuesPojoMethod = null; for (PojoMethod pojoMethod : pojoClass.getPojoMethods()) { if (pojoMethod.getName().equals...
#fixed code public Object doGenerate(final Class<?> type) { PojoClass pojoClass = PojoClassFactory.getPojoClass(type); Enum<?>[] values = getValues(pojoClass); if (values == null) { throw RandomGeneratorException.getInstance(MessageFormatter.format("F...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Object doGenerate(Parameterizable parameterizedType) { List returnedList = (List) RandomFactory.getRandomValue(parameterizedType.getType()); returnedList.clear(); CollectionHelper.buildCollections(returnedList, parameterizedType.getParamet...
#fixed code public Object doGenerate(Parameterizable parameterizedType) { return CollectionHelper.buildCollections((Collection) doGenerate(parameterizedType.getType()), parameterizedType.getParameterTypes() .get(0)); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public List<PojoPackage> getPojoSubPackages() { List<PojoPackage> pojoPackageSubPackages = new LinkedList<PojoPackage>(); File directory = PackageHelper.getPackageAsDirectory(packageName); for (File entry : directory.listFiles()) { i...
#fixed code public List<PojoPackage> getPojoSubPackages() { List<PojoPackage> pojoPackageSubPackages = new LinkedList<PojoPackage>(); List<File> paths = PackageHelper.getPackageDirectories(packageName); for (File path : paths) { for (File entry : path...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test(expected = ReflectionException.class) public void shouldFailSetter() { PojoField pojoField = getPrivateStringField(); pojoField.invokeSetter(null, RandomFactory.getRandomValue(pojoField.getType())); } #location 4 ...
#fixed code @Test(expected = ReflectionException.class) public void shouldFailSetter() { PojoField pojoField = getPrivateStringField(); assert pojoField != null; pojoField.invokeSetter(null, RandomFactory.getRandomValue(pojoField.getType())); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Object doGenerate(Parameterizable parameterizedType) { Queue returnedQueue = (Queue) RandomFactory.getRandomValue(parameterizedType.getType()); returnedQueue.clear(); CollectionHelper.buildCollections(returnedQueue, parameterizedType.getPa...
#fixed code public Object doGenerate(Parameterizable parameterizedType) { Queue returnedQueue = (Queue) RandomFactory.getRandomValue(parameterizedType.getType()); CollectionHelper.buildCollections(returnedQueue, parameterizedType.getParameterTypes().get(0)); retur...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test(expected = ReflectionException.class) public void shouldFailGet() { PojoField pojoField = getPrivateStringField(); pojoField.get(null); } #location 4 #vulnerability type NULL_DEREFERENCE
#fixed code @Test(expected = ReflectionException.class) public void shouldFailGet() { PojoField pojoField = getPrivateStringField(); assert pojoField != null; pojoField.get(null); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void run(final PojoClass pojoClass) { IdentityFactory.registerIdentityHandler(identityHandlerStub); firstPojoClassInstance = ValidationHelper.getMostCompleteInstance(pojoClass); secondPojoClassInstance = ValidationHelper.getMostCompleteInstance(pojoCla...
#fixed code public void run(final PojoClass pojoClass) { Object instance1 = ValidationHelper.getMostCompleteInstance(pojoClass); Object instance2 = ValidationHelper.getMostCompleteInstance(pojoClass); IdentityHandlerStub identityHandlerStub = new IdentityHandlerStub(instance1,...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Object doGenerate(final Class<?> type) { if (type == boolean.class || type == Boolean.class) { return RANDOM.nextBoolean(); } if (type == int.class || type == Integer.class) { return RANDOM.nextInt(); } ...
#fixed code public Object doGenerate(final Class<?> type) { if (type == boolean.class || type == Boolean.class) { return RANDOM.nextBoolean(); } if (type == int.class || type == Integer.class) { return RANDOM.nextInt(); } ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test(expected = ReflectionException.class) public void shouldFailSet() { PojoField pojoField = getPrivateStringField(); pojoField.set(null, RandomFactory.getRandomValue(pojoField.getType())); } #location 4 ...
#fixed code @Test(expected = ReflectionException.class) public void shouldFailSet() { PojoField pojoField = getPrivateStringField(); assert pojoField != null; pojoField.set(null, RandomFactory.getRandomValue(pojoField.getType())); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Object doGenerate(final Class<?> type) { if (type == boolean.class || type == Boolean.class) { return RANDOM.nextBoolean(); } if (type == int.class || type == Integer.class) { return RANDOM.nextInt(); } ...
#fixed code public Object doGenerate(final Class<?> type) { if (type == boolean.class || type == Boolean.class) { return RANDOM.nextBoolean(); } if (type == int.class || type == Integer.class) { return RANDOM.nextInt(); } ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void defaultRandomGeneratorServicePrePopulated() { // JDK 5 only supports 42 of the 44 possible types. (java.util.ArrayDeque does not exist in JDK5). String javaVersion = System.getProperty("java.version"); if (javaVersion.starts...
#fixed code @Test public void defaultRandomGeneratorServicePrePopulated() { reportDifferences(); Affirm.affirmEquals("Types added / removed?", expectedTypes, randomGeneratorService.getRegisteredTypes().size()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static List<Class<?>> getClasses(final String packageName) { List<Class<?>> classes = new LinkedList<Class<?>>(); File directory = getPackageAsDirectory(packageName); for (File entry : directory.listFiles()) { if (isClass(ent...
#fixed code public static List<Class<?>> getClasses(final String packageName) { List<Class<?>> classes = new LinkedList<Class<?>>(); List<File> paths = getPackageDirectories(packageName); for (File path : paths) { for (File entry : path.listFiles()) ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public int find(int[] numbers, int position) { validateInput(numbers, position); Integer result = null; Map<Integer, Integer> counter = new HashMap<Integer, Integer>(); for (int i : numbers) { if (counter.get(i) == null) { counter.put(i, 1); ...
#fixed code public int find(int[] numbers, int position) { validateInput(numbers, position); Integer result = null; Map<Integer, Integer> counter = new LinkedHashMap<Integer, Integer>(); for (int i : numbers) { if (counter.get(i) == null) { counter.put(i, 1); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private ElementSerializer startDoc( XmlSerializer serializer, Object element, boolean errorOnUnknown, String extraNamespace) throws IOException { serializer.startDocument(null, null); SortedSet<String> aliases = new TreeSet<String>(); computeAliase...
#fixed code private ElementSerializer startDoc( XmlSerializer serializer, Object element, boolean errorOnUnknown, String extraNamespace) throws IOException { serializer.startDocument(null, null); SortedSet<String> aliases = new TreeSet<String>(); computeAliases(elem...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @SuppressWarnings("unchecked") public static void parse(String content, Object data) { Class<?> clazz = data.getClass(); ClassInfo classInfo = ClassInfo.of(clazz); GenericData genericData = GenericData.class.isAssignableFrom(clazz) ? (GenericData) data : nul...
#fixed code @SuppressWarnings("unchecked") public static void parse(String content, Object data) { Class<?> clazz = data.getClass(); ClassInfo classInfo = ClassInfo.of(clazz); GenericData genericData = GenericData.class.isAssignableFrom(clazz) ? (GenericData) data : null; ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void parse(String content, Object data) { if (content == null) { return; } Class<?> clazz = data.getClass(); ClassInfo classInfo = ClassInfo.of(clazz); GenericData genericData = GenericData.class.isAssignableFrom(clazz) ? (GenericDa...
#fixed code public static void parse(String content, Object data) { if (content == null) { return; } Class<?> clazz = data.getClass(); ClassInfo classInfo = ClassInfo.of(clazz); GenericData genericData = GenericData.class.isAssignableFrom(clazz) ? (GenericData) da...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void should_run_post_build() { ConfigSection afterRunSection = new AfterRunSection(configListOrSingleValue("spec integration1", "spec integration2")); Combination combination = new Combination(ImmutableMap.of("script", "post_build")); assertTrue(afterR...
#fixed code @Test public void should_run_post_build() { ConfigSection afterRunSection = new AfterRunSection(configListOrSingleValue("spec integration1", "spec integration2")); Combination combination = new Combination(ImmutableMap.of("script", "post_build")); assertTrue(afterRunSect...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Run getPreviousFinishedBuildOfSameBranch(BuildListener listener) { return new DynamicBuildRepository().getPreviousFinishedBuildOfSameBranch(this, getCurrentBranch().toString()); } #location 2 #...
#fixed code public Run getPreviousFinishedBuildOfSameBranch(BuildListener listener) { return SetupConfig.get().getDynamicBuildRepository() .getPreviousFinishedBuildOfSameBranch(this, getCurrentBranch().toString()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static byte[] loadBytes(String filename) { InputStream input = classLoader().getResourceAsStream(filename); if (input == null) { File file = new File(filename); if (file.exists()) { try { input = new FileInputStream(filename); } catch (FileN...
#fixed code public static byte[] loadBytes(String filename) { InputStream input = null; try { input = classLoader().getResourceAsStream(filename); if (input == null) { File file = new File(filename); if (file.exists()) { try { input = new FileInputStream(filen...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public Object handle(HttpExchange x) throws Exception { String code = x.param("code"); String state = x.param("state"); U.debug("Received OAuth code", "code", code, "state", state); if (code != null && state != null) { U.must(stateCheck.isValidState...
#fixed code @Override public Object handle(HttpExchange x) throws Exception { String code = x.param("code"); String state = x.param("state"); U.debug("Received OAuth code", "code", code, "state", state); if (code != null && state != null) { U.must(stateCheck.isValidState(state...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ScanParams that = (ScanParams) o; if (!Arrays.equals(packages, that.packages)) return false; if (matching != null ? !matching.equ...
#fixed code @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ScanParams that = (ScanParams) o; if (!Arrays.equals(packages, that.packages)) return false; if (matching != null ? !matching.equals(th...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void reset() { super.reset(); isGet.value = false; isKeepAlive.value = false; verb.reset(); uri.reset(); path.reset(); query.reset(); protocol.reset(); body.reset(); multipartBoundary.reset(); params.reset(); headersKV.reset(); ...
#fixed code @Override public void reset() { super.reset(); isGet.value = false; isKeepAlive.value = false; verb.reset(); uri.reset(); path.reset(); query.reset(); protocol.reset(); body.reset(); multipartBoundary.reset(); params.reset(); headersKV.reset(); head...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void reset() { super.reset(); isGet.value = false; isKeepAlive.value = false; verb.reset(); uri.reset(); path.reset(); query.reset(); protocol.reset(); body.reset(); multipartBoundary.reset(); params.reset(); headersKV.reset(); ...
#fixed code @Override public void reset() { super.reset(); isGet.value = false; isKeepAlive.value = false; verb.reset(); uri.reset(); path.reset(); query.reset(); protocol.reset(); body.reset(); multipartBoundary.reset(); params.reset(); headersKV.reset(); head...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public Object getParamValue(Req req, Class<?> paramType, String paramName, Map<String, Object> properties) throws Exception { return Customization.of(req).jackson().convertValue(properties, paramType); } #location 3 ...
#fixed code @Override public Object getParamValue(Req req, Class<?> paramType, String paramName, Map<String, Object> properties) throws Exception { return Customization.of(req).objectMapper().convertValue(properties, paramType); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void reset() { super.reset(); isGet.value = false; isKeepAlive.value = false; verb.reset(); uri.reset(); path.reset(); query.reset(); protocol.reset(); body.reset(); multipartBoundary.reset(); params.reset(); headersKV.reset(); ...
#fixed code @Override public void reset() { super.reset(); isGet.value = false; isKeepAlive.value = false; verb.reset(); uri.reset(); path.reset(); query.reset(); protocol.reset(); body.reset(); multipartBoundary.reset(); params.reset(); headersKV.reset(); head...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static Db db() { assert U.must(defaultDb != null, "Database not initialized!"); return defaultDb; } #location 3 #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code public static Db db() { assert U.must(db != null, "Database not initialized!"); return db; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private Set<String> userRoles(Req req, String username) { if (username != null) { try { return req.routes().custom().rolesProvider().getRolesForUser(req, username); } catch (Exception e) { throw U.rte(e); } } else { return Collections.emptySet(); ...
#fixed code private Set<String> userRoles(Req req, String username) { if (username != null) { try { return Customization.of(req).rolesProvider().getRolesForUser(req, username); } catch (Exception e) { throw U.rte(e); } } else { return Collections.emptySet(); } }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public int hashCode() { int result = Arrays.hashCode(packages); result = 31 * result + (matching != null ? matching.hashCode() : 0); result = 31 * result + Arrays.hashCode(annotated); result = 31 * result + (classLoader != null ? classLoader.hashCode() :...
#fixed code @Override public int hashCode() { int result = Arrays.hashCode(packages); result = 31 * result + (matching != null ? matching.hashCode() : 0); result = 31 * result + Arrays.hashCode(annotated); result = 31 * result + (classLoader != null ? classLoader.hashCode() : 0); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void renderJson(Req req, Object value, OutputStream out) throws Exception { req.custom().jackson().writeValue(out, value); } #location 3 #vulnerability type NULL_DEREFERENCE
#fixed code @Override public void renderJson(Req req, Object value, OutputStream out) throws Exception { Customization.of(req).jackson().writeValue(out, value); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test(timeout = 30000) public void testJDBCWithTextConfig() { Conf.JDBC.set("driver", "org.h2.Driver"); Conf.JDBC.set("url", "jdbc:h2:mem:mydb"); Conf.JDBC.set("username", "sa"); Conf.C3P0.set("maxPoolSize", "123"); JDBC.defaultApi().pooled(); JdbcClient jd...
#fixed code @Test(timeout = 30000) public void testJDBCWithTextConfig() { Conf.JDBC.set("driver", "org.h2.Driver"); Conf.JDBC.set("url", "jdbc:h2:mem:mydb"); Conf.JDBC.set("username", "sa"); Conf.C3P0.set("maxPoolSize", "123"); JdbcClient jdbc = JDBC.defaultApi(); eq(jdbc.dri...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void complete(Channel ctx, boolean isKeepAlive, Req req, Object result) { if (result == null) { http.notFound(ctx, isKeepAlive, this, req); return; // not found } if (result instanceof HttpStatus) { complete(ctx, isKeepAlive, req, U.rte("HttpStatus ...
#fixed code public void complete(Channel ctx, boolean isKeepAlive, Req req, Object result) { if (result == null) { http.notFound(ctx, isKeepAlive, this, req); return; // not found } if (result instanceof HttpStatus) { complete(ctx, isKeepAlive, req, U.rte("HttpStatus result...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test(timeout = 30000) public void testHikariPool() { JdbcClient jdbc = JDBC.api(); jdbc.h2("hikari-test"); jdbc.pool(new HikariConnectionPool(jdbc)); jdbc.execute("create table abc (id int, name varchar)"); jdbc.execute("insert into abc values (?, ?)", 123, "...
#fixed code @Test(timeout = 30000) public void testHikariPool() { Conf.HIKARI.set("maximumPoolSize", 234); JdbcClient jdbc = JDBC.api(); jdbc.h2("hikari-test"); jdbc.dataSource(HikariFactory.createDataSourceFor(jdbc)); jdbc.execute("create table abc (id int, name varchar)"); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void reset() { super.reset(); isGet.value = false; isKeepAlive.value = false; verb.reset(); uri.reset(); path.reset(); query.reset(); protocol.reset(); body.reset(); multipartBoundary.reset(); params.reset(); headersKV.reset(); ...
#fixed code @Override public void reset() { super.reset(); isGet.value = false; isKeepAlive.value = false; verb.reset(); uri.reset(); path.reset(); query.reset(); protocol.reset(); body.reset(); multipartBoundary.reset(); params.reset(); headersKV.reset(); head...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ScanParams that = (ScanParams) o; if (!Arrays.equals(packages, that.packages)) return false; if (matching != null ? !matching.equ...
#fixed code @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ScanParams that = (ScanParams) o; if (!Arrays.equals(packages, that.packages)) return false; if (matching != null ? !matching.equals(th...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static Object emit(HttpExchange x) { int event = U.num(x.data("event")); TagContext ctx = x.session(SESSION_CTX, null); // if the context has been lost, reload the page if (ctx == null) { return changes(x, PAGE_RELOAD); } Cmd cmd = ctx.getEventCmd(...
#fixed code public static Object emit(HttpExchange x) { int event = U.num(x.data("event")); TagContext ctx = x.session(SESSION_CTX, null); // if the context has been lost, reload the page if (ctx == null) { return changes(x, PAGE_RELOAD); } Cmd cmd = ctx.getEventCmd(event)...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public String get() { return count > 0 ? String.format("[%s..%s..%s]/%s", min, sum / count, max, count) : null; } #location 3 #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code @Override public String get() { return count > 0 ? String.format("%s:[%s..%s..%s]#%s", sum, min, sum / count, max, count) : "" + ticks; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void complete(Channel ctx, boolean isKeepAlive, Req req, Object result) { if (result == null) { http.notFound(ctx, isKeepAlive, this, req); return; // not found } if (result instanceof HttpStatus) { complete(ctx, isKeepAlive, req, U.rte("HttpStatus ...
#fixed code public void complete(Channel ctx, boolean isKeepAlive, Req req, Object result) { if (result == null) { http.notFound(ctx, isKeepAlive, this, req); return; // not found } if (result instanceof HttpStatus) { complete(ctx, isKeepAlive, req, U.rte("HttpStatus result...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public HttpExchangeBody goBack(int steps) { List<String> stack = session(SESSION_PAGE_STACK, null); String dest = !stack.isEmpty() ? stack.get(stack.size() - 1) : "/"; for (int i = 0; i < steps; i++) { if (stack != null && !stack.isEmpty()) { stac...
#fixed code @Override public HttpExchangeBody goBack(int steps) { String dest = "/"; List<String> stack = session(SESSION_PAGE_STACK, null); if (stack != null) { if (!stack.isEmpty()) { dest = stack.get(stack.size() - 1); } for (int i = 0; i < steps; i++) { if (!st...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private byte[] responseToBytes() { try { return response.renderToBytes(); } catch (Throwable e) { HttpIO.error(this, e, Customization.of(this).errorHandler()); try { return response.renderToBytes(); } catch (Exception e1) { Log.error("Internal re...
#fixed code private byte[] responseToBytes() { try { return response.renderToBytes(); } catch (Throwable e) { HttpIO.error(this, e); try { return response.renderToBytes(); } catch (Exception e1) { Log.error("Internal rendering error!", e1); return HttpUtils.ge...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Future<byte[]> get(String uri, Callback<byte[]> callback) { HttpGet req = new HttpGet(uri); Log.debug("Starting HTTP GET request", "request", req.getRequestLine()); return execute(client, req, callback); } #location 6 ...
#fixed code public Future<byte[]> get(String uri, Callback<byte[]> callback) { return request("GET", uri, null, null, null, null, null, callback); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void process(Channel ctx) { if (ctx.isInitial()) { return; } Buf buf = ctx.input(); RapidoidHelper helper = ctx.helper(); Range[] ranges = helper.ranges1.ranges; Ranges hdrs = helper.ranges2; BoolWrap isGet = helper.booleans[0]; BoolWrap isKeep...
#fixed code public void process(Channel ctx) { if (ctx.isInitial()) { return; } Buf buf = ctx.input(); RapidoidHelper helper = ctx.helper(); Range[] ranges = helper.ranges1.ranges; Ranges hdrs = helper.ranges2; BoolWrap isGet = helper.booleans[0]; BoolWrap isKeepAlive ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void addInfo(List<Object> info, final GroupOf<?> group, List<? extends Manageable> items, List<String> columns) { columns.add("(Actions)"); final String groupName = group.name(); String type = U.first(items).getManageableType(); info.add(breadcrumb(type, g...
#fixed code private void addInfo(List<Object> info, final GroupOf<?> group, List<? extends Manageable> items, List<String> columns) { columns.add("(Actions)"); final String groupName = group.name(); final String kind = group.kind(); info.add(breadcrumb(kind, groupName)); Grid gr...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ScanParams that = (ScanParams) o; if (!Arrays.equals(packages, that.packages)) return false; if (matching != null ? !matching.equ...
#fixed code @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ScanParams that = (ScanParams) o; if (!Arrays.equals(packages, that.packages)) return false; if (matching != null ? !matching.equals(th...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private static List<Class<?>> getClassesFromJAR(String jarName, List<Class<?>> classes, String pkg, Pattern regex, Predicate<Class<?>> filter, Class<? extends Annotation> annotated, ClassLoader classLoader) { try { String pkgPath = pkgToPath(pkg); ZipInputStrea...
#fixed code private static List<Class<?>> getClassesFromJAR(String jarName, List<Class<?>> classes, String pkg, Pattern regex, Predicate<Class<?>> filter, Class<? extends Annotation> annotated, ClassLoader classLoader) { ZipInputStream zip = null; try { String pkgPath = pkgToPath...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static String load(String filename) { return new String(loadBytes(filename)); } #location 2 #vulnerability type NULL_DEREFERENCE
#fixed code public static String load(String filename) { byte[] bytes = loadBytes(filename); return bytes != null ? new String(bytes) : null; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @SuppressWarnings("unchecked") public static WebApp bootstrap(WebApp app, String[] args, Object... config) { Log.info("Starting Rapidoid...", "version", RapidoidInfo.version()); ConfigHelp.processHelp(args); // FIXME make optional // print internal state // Lo...
#fixed code @SuppressWarnings("unchecked") public static WebApp bootstrap(WebApp app, String[] args, Object... config) { Log.info("Starting Rapidoid...", "version", RapidoidInfo.version()); ConfigHelp.processHelp(args); // FIXME make optional // print internal state // LoggerCo...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public Object call() throws Exception { List<Object> info = U.list(); for (GroupOf<?> group : Groups.all()) { List<? extends Manageable> items = group.items(); if (U.notEmpty(items)) { List<String> columns = U.first(items).getManageableProperties...
#fixed code @Override public Object call() throws Exception { List<Object> info = U.list(); Collection<? extends GroupOf<?>> targetGroups = groups != null ? groups : Groups.all(); for (GroupOf<?> group : targetGroups) { List<? extends Manageable> items = group.items(); List<...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void shouldParseRequest1() { ReqData req = parse(REQ1); BufGroup bufs = new BufGroup(2); Buf reqbuf = bufs.from(REQ1, "r2"); eq(REQ1, req.rVerb, "GET"); eq(REQ1, req.rPath, "/foo/bar"); eqs(REQ1, req.params, "a", "5", "b", "", "n", "%20"); eq(...
#fixed code @Test public void shouldParseRequest1() { RapidoidHelper req = parse(REQ1); BufGroup bufs = new BufGroup(2); Buf reqbuf = bufs.from(REQ1, "r2"); eq(REQ1, req.verb, "GET"); eq(REQ1, req.path, "/foo/bar"); eqs(REQ1, req.params, "a", "5", "b", "", "n", "%20"); eq(r...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private static void generateIndex(String path) { System.out.println(); System.out.println(); System.out.println("*************** " + path); System.out.println(); System.out.println(); List<Map<String, ?>> examples = U.list(); IntWrap nn = new IntWrap(); ...
#fixed code private static void generateIndex(String path) { System.out.println(); System.out.println(); System.out.println("*************** " + path); System.out.println(); System.out.println(); List<Map<String, ?>> examplesl = U.list(); IntWrap nl = new IntWrap(); List<St...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public int hashCode() { int result = Arrays.hashCode(packages); result = 31 * result + (matching != null ? matching.hashCode() : 0); result = 31 * result + Arrays.hashCode(annotated); result = 31 * result + (classLoader != null ? classLoader.hashCode() :...
#fixed code @Override public int hashCode() { int result = Arrays.hashCode(packages); result = 31 * result + (matching != null ? matching.hashCode() : 0); result = 31 * result + Arrays.hashCode(annotated); result = 31 * result + (classLoader != null ? classLoader.hashCode() : 0); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void render(Req req, Object value, OutputStream out) throws Exception { Customization.of(req).jacksonXml().writeValue(out, value); } #location 3 #vulnerability type NULL_DEREFERENCE
#fixed code @Override public void render(Req req, Object value, OutputStream out) throws Exception { Customization.of(req).xmlMapper().writeValue(out, value); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override protected void doProcessing() { long now = U.time(); int connectingN = connecting.size(); for (int i = 0; i < connectingN; i++) { ConnectionTarget target = connecting.poll(); assert target != null; if (target.retryAfter < now) { Log.debug("...
#fixed code @Override protected void doProcessing() { long now = U.time(); int connectingN = connecting.size(); for (int i = 0; i < connectingN; i++) { ConnectionTarget target = connecting.poll(); assert target != null; if (target.retryAfter < now) { Log.debug("connec...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void verifyCase(String info, String actual, String testCaseName) { String s = File.separator; String resname = "results" + s + testName() + s + getTestMethodName() + s + testCaseName; String filename = "src" + s + "test" + s + "resources" + s + resname; ...
#fixed code protected void verifyCase(String info, String actual, String testCaseName) { String s = File.separator; String resname = "results" + s + testName() + s + getTestMethodName() + s + testCaseName; String filename = "src" + s + "test" + s + "resources" + s + resname; if (AD...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private boolean handleError(Channel channel, boolean isKeepAlive, ReqImpl req, MediaType contentType, Throwable e) { if (req != null) { if (!req.isStopped()) { HttpIO.errorAndDone(req, e); } return true; } else { Log.error("Low-level HTTP handler error...
#fixed code private boolean handleError(Channel channel, boolean isKeepAlive, ReqImpl req, MediaType contentType, Throwable e) { if (req != null) { if (!req.isStopped()) { try { HttpIO.errorAndDone(req, e); } catch (Exception e1) { Log.error("HTTP error handler error!...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public int hashCode() { int result = Arrays.hashCode(packages); result = 31 * result + (matching != null ? matching.hashCode() : 0); result = 31 * result + Arrays.hashCode(annotated); result = 31 * result + (classLoader != null ? classLoader.hashCode() :...
#fixed code @Override public int hashCode() { int result = Arrays.hashCode(packages); result = 31 * result + (matching != null ? matching.hashCode() : 0); result = 31 * result + Arrays.hashCode(annotated); result = 31 * result + (classLoader != null ? classLoader.hashCode() : 0); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test(timeout = 30000) public void testHikariPool() { JdbcClient jdbc = JDBC.api(); jdbc.h2("hikari-test"); jdbc.pool(new HikariConnectionPool(jdbc)); jdbc.execute("create table abc (id int, name varchar)"); jdbc.execute("insert into abc values (?, ?)", 123, "...
#fixed code @Test(timeout = 30000) public void testHikariPool() { Conf.HIKARI.set("maximumPoolSize", 234); JdbcClient jdbc = JDBC.api(); jdbc.h2("hikari-test"); jdbc.dataSource(HikariFactory.createDataSourceFor(jdbc)); jdbc.execute("create table abc (id int, name varchar)"); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private static <T> void invokePostConstruct(T target) { List<Method> methods = Cls.getMethodsAnnotated(target.getClass(), Init.class); for (Method method : methods) { Cls.invoke(null, method, target); } } #location 5 ...
#fixed code private static <T> void invokePostConstruct(T target) { List<Method> methods = Cls.getMethodsAnnotated(target.getClass(), Init.class); for (Method method : methods) { Cls.invoke(method, target); } }
Below is the vulnerable code, please generate the patch based on the following information.