input
stringlengths
205
73.3k
output
stringlengths
64
73.2k
instruction
stringclasses
1 value
#vulnerable code @Override public Transaction getTx(NulsDigestData hash) { TransactionLocalPo localPo = localTxDao.get(hash.getDigestHex()); if (localPo != null) { try { Transaction tx = UtxoTransferTool.toTransaction(localPo); ...
#fixed code @Override public Transaction getTx(NulsDigestData hash) { TransactionPo po = txDao.get(hash.getDigestHex()); if (null != po) { try { Transaction tx = UtxoTransferTool.toTransaction(po); return tx; } c...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public Result<Account> importAccount(String prikey, String password) { if (!ECKey.isValidPrivteHex(prikey)) { return Result.getFailed(AccountErrorCode.PARAMETER_ERROR); } Account account; try { accoun...
#fixed code @Override public Result<Account> importAccount(String prikey, String password) { if (!ECKey.isValidPrivteHex(prikey)) { return Result.getFailed(AccountErrorCode.PARAMETER_ERROR); } Account account; try { account = Ac...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void reSendLocalTx() throws NulsException { List<Transaction> txList = getLedgerCacheService().getUnconfirmTxList(); List<Transaction> helpList = new ArrayList<>(); for (Transaction tx : txList) { if (TimeService.currentTimeMi...
#fixed code private void reSendLocalTx() throws NulsException { List<Transaction> txList = ledgerCacheService.getUnconfirmTxList(); List<Transaction> helpList = new ArrayList<>(); for (Transaction tx : txList) { if (TimeService.currentTimeMillis() - tx...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void start() { Log.debug("Start"); notificationController = new NotificationController(); EventBusService eventBusService = NulsContext.getServiceBean(EventBusService.class); eventBusService.subscribeEvent(BaseEvent....
#fixed code @Override public void start() { Log.debug("Start"); notificationController = new NotificationController(); EventBusService eventBusService = NulsContext.getServiceBean(EventBusService.class); eventBusService.subscribeEvent(BaseEvent.class,...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public boolean isLocalHasSeed(List<Account> accountList) { for (Account account : accountList) { for (PocMeetingMember seed : this.getDefaultSeedList()) { if (seed.getAgentAddress().equals(account.getAddress().getBase58())) { ...
#fixed code public boolean isLocalHasSeed(List<Account> accountList) { for (Account account : accountList) { for (String seedAddress : csManager.getSeedNodeList()) { if (seedAddress.equals(account.getAddress().getBase58())) { return...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void start() { try { ChannelFuture future = boot.connect(node.getIp(), node.getSeverPort()).sync(); if (future.isSuccess()) { socketChannel = (SocketChannel) future.channel(); } else { Sy...
#fixed code public void start() { try { ChannelFuture future = boot.connect(node.getIp(), node.getSeverPort()).addListener(new ChannelFutureListener() { @Override public void operationComplete(ChannelFuture future) throws Exception { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public List<Transaction> getWaitingTxList() throws NulsException { List<TransactionLocalPo> poList = localTxDao.getUnConfirmTxs(); List<Transaction> txList = new ArrayList<>(); for (TransactionLocalPo po : poList) { Tran...
#fixed code @Override public List<Transaction> getWaitingTxList() throws NulsException { return ledgerCacheService.getUnconfirmTxList(); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void start() { this.waitForDependencyRunning(MessageBusConstant.MODULE_ID_MESSAGE_BUS); this.initHandlers(); ((DownloadServiceImpl) NulsContext.getServiceBean(DownloadService.class)).start(); } ...
#fixed code @Override public void start() { this.waitForDependencyRunning(MessageBusConstant.MODULE_ID_MESSAGE_BUS); this.waitForDependencyInited(ConsensusConstant.MODULE_ID_CONSENSUS); this.initHandlers(); ((DownloadServiceImpl) NulsContext.getService...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override protected void parse(NulsByteBuffer byteBuffer) throws NulsException { alias = new String(byteBuffer.readByLengthByte()); address = new Address(new String(byteBuffer.readByLengthByte())); encryptedPriKey = byteBuffer.readByLengthByt...
#fixed code @Override protected void parse(NulsByteBuffer byteBuffer) throws NulsException { address = Address.fromHashs(byteBuffer.readByLengthByte()); alias = new String(byteBuffer.readByLengthByte()); encryptedPriKey = byteBuffer.readByLengthByte(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void calc() { if (null == nodeIdList || nodeIdList.isEmpty()) { throw new NulsRuntimeException(ErrorCode.FAILED, "success list of nodes is empty!"); } int size = nodeIdList.size(); int halfSize = (size + 1) / 2; ...
#fixed code private void calc() { if (null == nodeIdList || nodeIdList.isEmpty()) { throw new NulsRuntimeException(ErrorCode.FAILED, "success list of nodes is empty!"); } int size = nodeIdList.size(); int halfSize = (size + 1) / 2; //t...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public TransferTransaction createTransferTx(CoinTransferData transferData, String password, String remark) throws Exception { TransferTransaction tx = new TransferTransaction(transferData, password); tx.setRemark(remark.getBytes(NulsContext.DEFAULT_ENCOD...
#fixed code public TransferTransaction createTransferTx(CoinTransferData transferData, String password, String remark) throws Exception { TransferTransaction tx = new TransferTransaction(transferData, password); tx.setRemark(remark.getBytes(NulsContext.DEFAULT_ENCODING));...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void handleKey(SelectionKey key) { ConnectionHandler handler = (ConnectionHandler) key.attachment(); try { if (!key.isValid()) { // Key has been cancelled, make sure the socket gets closed System....
#fixed code public static void handleKey(SelectionKey key) { ConnectionHandler handler = (ConnectionHandler) key.attachment(); try { if (!key.isValid()) { // Key has been cancelled, make sure the socket gets closed System.out.pr...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public HeaderDigest getLastHd() { if (null == lastHd) { List<HeaderDigest> list = new ArrayList<>(headerDigestList); if(list.size() > 0) { this.lastHd = list.get(list.size() - 1); } } return las...
#fixed code public HeaderDigest getLastHd() { List<HeaderDigest> list = new ArrayList<>(headerDigestList); if (list.size() > 0) { return list.get(list.size() - 1); } return null; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public double readDouble() throws NulsException { return Utils.bytes2Double(this.readByLengthByte()); } #location 2 #vulnerability type NULL_DEREFERENCE
#fixed code public double readDouble() throws NulsException { byte[] bytes = this.readByLengthByte(); if(null==bytes){ return 0; } return Utils.bytes2Double(bytes); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public boolean addBlockHashResponse(String nodeId, BlockHashResponse response) { if (!hashesMap.containsKey(nodeId)) { return false; } if (!requesting) { return false; } if(hashesMap.get(nodeId)==null){ ...
#fixed code public boolean addBlockHashResponse(String nodeId, BlockHashResponse response) { if (!hashesMap.containsKey(nodeId)) { return false; } if (!requesting) { return false; } if (hashesMap.get(nodeId) == null) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public ValidateResult validate(AliasTransaction tx) { Alias alias = tx.getTxData(); if (!Address.validAddress(alias.getAddress())) { return ValidateResult.getFailedResult("The address format error"); } if (!Strin...
#fixed code @Override public ValidateResult validate(AliasTransaction tx) { Alias alias = tx.getTxData(); if (!Address.validAddress(alias.getAddress())) { return ValidateResult.getFailedResult(ErrorCode.ADDRESS_ERROR); } if (!StringUtils.va...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testRun() { assertNotNull(blockProcessTask); ConsensusStatusContext.setConsensusStatus(ConsensusStatus.WAIT_START); blockProcessTask.run(); assert(!ConsensusStatusContext.isRunning()); ConsensusDownloadSe...
#fixed code @Test public void testRun() { assertNotNull(blockProcessTask); if(downloadService.isDownloadSuccess().isSuccess()) { downloadService.setDownloadSuccess(false); } ConsensusStatusContext.setConsensusStatus(ConsensusStatus.WAIT_S...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void start() { List<Peer> peers = discovery.getLocalPeers(10); if (peers.isEmpty()) { peers = getSeedPeers(); } for (Peer peer : peers) { peer.setType(Peer.OUT); addPeerToGroup(NetworkConstant.N...
#fixed code public void start() { List<Peer> peers = discovery.getLocalPeers(10); if (peers.isEmpty()) { peers = getSeedPeers(); } for (Peer peer : peers) { peer.setType(Peer.OUT); addPeerToGroup(NetworkConstant.NETWORK...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public ValidateResult validate(AliasTransaction tx) { Alias alias = tx.getTxData(); if (StringUtils.isBlank(alias.getAddress()) || new Address(alias.getAddress()).getHash().length != 23) { return ValidateResult.getFailedResult("...
#fixed code @Override public ValidateResult validate(AliasTransaction tx) { Alias alias = tx.getTxData(); if (StringUtils.isBlank(alias.getAddress()) || new Address(alias.getAddress()).getHash().length != 23) { return ValidateResult.getFailedResult("The ad...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public Set<K> keySet(String cacheTitle) { Iterator it = cacheManager.getCache(cacheTitle).iterator(); Set<K> set = new HashSet<>(); while (it.hasNext()) { Cache.Entry<K, T> entry = (Cache.Entry<K, T>) it.next(); ...
#fixed code @Override public Set<K> keySet(String cacheTitle) { Cache cache = this.cacheManager.getCache(cacheTitle); if (null == cache) { return new HashSet<>(); } Iterator it = cache.iterator(); Set<K> set = new HashSet<>(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static Result createArea(String areaName) { // prevent too many areas if(AREAS.size() > (MAX -1)) { return new Result(false, "KV_AREA_CREATE_ERROR"); } if(StringUtils.isBlank(areaName)) { return Result.getFa...
#fixed code public static Result createArea(String areaName) { // prevent too many areas if(AREAS.size() > (MAX -1)) { return new Result(false, "KV_AREA_CREATE_ERROR"); } if(StringUtils.isBlank(areaName)) { return Result.getFailed(E...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void nextRound() throws NulsException, IOException { packingRoundManager.calc(getBestBlock()); while (TimeService.currentTimeMillis() < (packingRoundManager.getCurrentRound().getStartTime())) { try { Thread.sleep(100L)...
#fixed code private void nextRound() throws NulsException, IOException { packingRoundManager.calc(getBestBlock()); PocMeetingRound round = packingRoundManager.getCurrentRound(); while (TimeService.currentTimeMillis() < round.getStartTime()) { try { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void init() { //load five(CACHE_COUNT) round from db on the start time ; Block bestBlock = NulsContext.getInstance().getBestBlock(); BlockRoundData roundData = new BlockRoundData(bestBlock.getHeader().getExtend()); for (long i = ro...
#fixed code public void init() { //load five(CACHE_COUNT) round from db on the start time ; Block bestBlock = getBestBlock(); BlockRoundData roundData = new BlockRoundData(bestBlock.getHeader().getExtend()); for (long i = roundData.getRoundIndex(); i >= 1 ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public PocMeetingRound getCurrentRound() { Block currentBlock = NulsContext.getInstance().getBestBlock(); BlockRoundData currentRoundData = new BlockRoundData(currentBlock.getHeader().getExtend()); PocMeetingRound round = ROUND_MAP.get(currentRou...
#fixed code public PocMeetingRound getCurrentRound() { return currentRound; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void rollbackAppraval(Block block) { if (null == block) { Log.warn("the block is null!"); return; } this.rollbackTxList(block.getTxs(), 0, block.getTxs().size()); PackingRoundManager.getValidateInstance().c...
#fixed code private void rollbackAppraval(Block block) { if (null == block) { Log.warn("the block is null!"); return; } this.rollbackTxList(block.getTxs(), 0, block.getTxs().size()); Block preBlock =this.getBlock(block.getHeader().g...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void init() { //load five(CACHE_COUNT) round from db on the start time ; Block bestBlock = getBestBlock(); BlockRoundData roundData = new BlockRoundData(bestBlock.getHeader().getExtend()); for (long i = roundData.getRoundIndex(); i...
#fixed code public void init() { //load five(CACHE_COUNT) round from db on the start time ; Block bestBlock = getBestBlock(); BlockRoundData roundData = new BlockRoundData(bestBlock.getHeader().getExtend()); for (long i = roundData.getRoundIndex(); i >= 1 ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private PocMeetingRound calcNextRound(BlockHeader bestBlockHeader, long bestHeight, BlockRoundData bestRoundData) { PocMeetingRound round = new PocMeetingRound(); round.setIndex(bestRoundData.getRoundIndex() + 1); round.setStartTime(bestRoundData...
#fixed code private PocMeetingRound calcNextRound(BlockHeader bestBlockHeader, long bestHeight, BlockRoundData bestRoundData) { PocMeetingRound round = new PocMeetingRound(); round.setIndex(bestRoundData.getRoundIndex() + 1); round.setStartTime(bestRoundData.getRo...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public Result<Balance> getBalance(byte[] address) throws NulsException { if (address == null || address.length != AddressTool.HASH_LENGTH) { return Result.getFailed(AccountLedgerErrorCode.PARAMETER_ERROR); } if (!isLoca...
#fixed code @Override public Result<Balance> getBalance(byte[] address) throws NulsException { if (address == null || address.length != AddressTool.HASH_LENGTH) { return Result.getFailed(AccountLedgerErrorCode.PARAMETER_ERROR); } if (!isLocalAccou...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public boolean processingBifurcation(long height) { return this.bifurcateProcessor.processing(height); } #location 2 #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code public boolean processingBifurcation(long height) { lock.lock(); try { return this.bifurcateProcessor.processing(height); } finally { lock.unlock(); } }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static UtxoOutputPo toOutputPojo(UtxoOutput output) { UtxoOutputPo po = new UtxoOutputPo(); po.setTxHash(output.getTxHash().getDigestHex()); po.setOutIndex(output.getIndex()); po.setValue(output.getValue()); po.setLockTime(...
#fixed code public static UtxoOutputPo toOutputPojo(UtxoOutput output) { UtxoOutputPo po = new UtxoOutputPo(); po.setTxHash(output.getTxHash().getDigestHex()); po.setOutIndex(output.getIndex()); po.setValue(output.getValue()); po.setLockTime(output...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public ValidateResult validate(AbstractCoinTransaction tx) { UtxoData data = (UtxoData) tx.getCoinData(); for (int i = 0; i < data.getInputs().size(); i++) { UtxoInput input = data.getInputs().get(i); UtxoOutput outp...
#fixed code @Override public ValidateResult validate(AbstractCoinTransaction tx) { UtxoData data = (UtxoData) tx.getCoinData(); for (int i = 0; i < data.getInputs().size(); i++) { UtxoInput input = data.getInputs().get(i); UtxoOutput output = i...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public BlockInfo request(long height, List<String> sendList) { return this.request(height, height, 1,nodeIdList); } #location 2 #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code public BlockInfo request(long height, List<String> sendList) { return this.request(height, height, 1, sendList); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void cacheBlockToBuffer(Block block) { blockCacheBuffer.cacheBlock(block); BlockLog.info("orphan cache block height:" + block.getHeader().getHeight() + ", preHash:" + block.getHeader().getPreHash() + " , hash:" + block.getHeader().getHash() + ", ...
#fixed code private void cacheBlockToBuffer(Block block) { blockCacheBuffer.cacheBlock(block); BlockLog.info("orphan cache block height:" + block.getHeader().getHeight() + ", preHash:" + block.getHeader().getPreHash() + " , hash:" + block.getHeader().getHash() + ", addres...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void addTx(Block block) { BlockHeader blockHeader = block.getHeader(); List<Transaction> txs = block.getTxs(); Transaction<Agent> agentTx = new CreateAgentTransaction(); Agent agent = new Agent(); agent...
#fixed code protected void addTx(Block block) { BlockHeader blockHeader = block.getHeader(); List<Transaction> txs = block.getTxs(); Transaction<Agent> agentTx = new CreateAgentTransaction(); Agent agent = new Agent(); agent.setPa...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void newTx() throws Exception { assertNotNull(service); // new a tx Transaction tx = new TestTransaction(); CoinData coinData = new CoinData(); List<Coin> fromList = new ArrayList<>(); fromList.add(new C...
#fixed code @Test public void newTx() throws Exception { assertNotNull(service); // new a tx Transaction tx = new TestTransaction(); CoinData coinData = new CoinData(); List<Coin> fromList = new ArrayList<>(); fromList.add(new Coin(ne...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void checkCache() { if (null == blockService) { blockService = NulsContext.getServiceBean(BlockService.class); } Block block = blockService.getBlock(blockService.getLocalSavedHeight()); boolean b = (TimeService.current...
#fixed code private void checkCache() { // if (null == blockService) { // blockService = NulsContext.getServiceBean(BlockService.class); // } // Block block = blockService.getBlock(blockService.getLocalSavedHeight()); // boolean b = (TimeService.cur...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public ValidateResult validate(AliasTransaction tx) { Alias alias = tx.getTxData(); if (StringUtils.isBlank(alias.getAddress()) || new Address(alias.getAddress()).getHash160().length > 25) { return ValidateResult.getFailedResult...
#fixed code @Override public ValidateResult validate(AliasTransaction tx) { Alias alias = tx.getTxData(); if (StringUtils.isBlank(alias.getAddress()) || new Address(alias.getAddress()).getHash().length !=23 ) { return ValidateResult.getFailedResult("The ad...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void init() { cacheService = LedgerCacheService.getInstance(); registerService(); ledgerService = NulsContext.getServiceBean(LedgerService.class); coinManager = UtxoCoinManager.getInstance(); UtxoOutputDataSer...
#fixed code @Override public void init() { cacheService = LedgerCacheService.getInstance(); registerService(); ledgerService = NulsContext.getServiceBean(LedgerService.class); coinManager = UtxoCoinManager.getInstance(); UtxoOutputDataService o...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void init(Map<String, String> initParams) { String dataBaseType = null; if(initParams.get("dataBaseType") != null) { dataBaseType = initParams.get("dataBaseType"); } if (!StringUtils.isEmpty(dataBaseType) ...
#fixed code @Override public void init(Map<String, String> initParams) { String databaseType = null; if(initParams.get("databaseType") != null) { databaseType = initParams.get("databaseType"); } if (!StringUtils.isEmpty(databaseType) && has...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void start() { getNetworkStorage().init(); List<Node> nodeList = getNetworkStorage().getLocalNodeList(20); nodeList.addAll(getSeedNodes()); for (Node node : nodeList) { addNode(node); } running = true; ...
#fixed code public void start() { List<Node> nodeList = getNetworkStorage().getLocalNodeList(20); nodeList.addAll(getSeedNodes()); for (Node node : nodeList) { addNode(node); } running = true; TaskManager.createAndRunThread(Netw...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public boolean resetSystem(String reason) { if ((TimeService.currentTimeMillis() - lastResetTime) <= INTERVAL_TIME) { Log.info("system reset interrupt!"); return true; } Log.info("---------------reset start--...
#fixed code @Override public boolean resetSystem(String reason) { if ((TimeService.currentTimeMillis() - lastResetTime) <= INTERVAL_TIME) { Log.info("system reset interrupt!"); return true; } Log.info("---------------reset start--------...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public HeaderDigest getLastHd() { if(null==lastHd){ List<HeaderDigest> list = new ArrayList<>(headerDigestList); this.lastHd = list.get(list.size()-1); } return lastHd; } #location 6 ...
#fixed code public HeaderDigest getLastHd() { if (null == lastHd) { List<HeaderDigest> list = new ArrayList<>(headerDigestList); this.lastHd = list.get(list.size() - 1); } return lastHd; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public NetworkEventResult process(BaseEvent event, Node node) { GetNodeEvent getNodeEvent = (GetNodeEvent) event; String key = event.getHeader().getEventType() + "-" + node.getIp(); if (cacheService.existEvent(key)) { g...
#fixed code @Override public NetworkEventResult process(BaseEvent event, Node node) { GetNodeEvent getNodeEvent = (GetNodeEvent) event; // String key = event.getHeader().getEventType() + "-" + node.getIp(); // if (cacheService.existEvent(key)) { // g...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void start() { List<Account> accounts = getAccountList(); Set<String> addressList = new HashSet<>(); if (accounts != null && !accounts.isEmpty()) { NulsContext.DEFAULT_ACCOUNT_ID = accounts.get(0).getAddress().get...
#fixed code @Override public void start() { getAccountList(); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public HeaderDigest getLastHd() { if (null == lastHd) { List<HeaderDigest> list = new ArrayList<>(headerDigestList); if(list.size() > 0) { this.lastHd = list.get(list.size() - 1); } } return las...
#fixed code public HeaderDigest getLastHd() { List<HeaderDigest> list = new ArrayList<>(headerDigestList); if (list.size() > 0) { return list.get(list.size() - 1); } return null; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public boolean processing(long height) { if (chainList.isEmpty()) { return false; } this.checkIt(); if (null == approvingChain) { return false; } if (approvingChain.getLastHd() != null && approvingC...
#fixed code public boolean processing(long height) { if (chainList.isEmpty()) { return false; } this.checkIt(); if (null == approvingChain) { return false; } Set<HeaderDigest> removeHashSet = new HashSet<>(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public ValidateResult validate(AbstractCoinTransaction tx) { UtxoData data = (UtxoData) tx.getCoinData(); for (int i = 0; i < data.getInputs().size(); i++) { UtxoInput input = data.getInputs().get(i); UtxoOutput outp...
#fixed code @Override public ValidateResult validate(AbstractCoinTransaction tx) { UtxoData data = (UtxoData) tx.getCoinData(); for (int i = 0; i < data.getInputs().size(); i++) { UtxoInput input = data.getInputs().get(i); UtxoOutput output = i...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @PluginFactory public static <S extends Serializable> SyslogAppender<S> createAppender(@PluginAttr("host") final String host, @PluginAttr("port") final String portNum, @P...
#fixed code @PluginFactory public static <S extends Serializable> SyslogAppender<S> createAppender(@PluginAttr("host") final String host, @PluginAttr("port") final String portNum, @PluginA...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private static OutputStream getOutputStream(final boolean follow, final Target target) { final PrintStream printStream = target == Target.SYSTEM_OUT ? follow ? new PrintStream(new SystemOutStream()) : System.out : follow ? new PrintStream...
#fixed code private static OutputStream getOutputStream(final boolean follow, final Target target) { final PrintStream printStream = target == Target.SYSTEM_OUT ? follow ? new PrintStream(new SystemOutStream()) : System.out : follow ? new PrintStream(new S...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testAppender() throws Exception { for (int i = 0; i < 8; ++i) { logger.debug("This is test message number " + i); } Thread.sleep(50); final File dir = new File(DIR); assertTrue("Directory not crea...
#fixed code @Test public void testAppender() throws Exception { for (int i = 0; i < 8; ++i) { logger.debug("This is test message number " + i); } Thread.sleep(50); final File dir = new File(DIR); assertThat(dir, both(exists()).and(h...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override protected void releaseSub() { if (rpcClient != null) { try { rpcClient.close(); } catch (final Exception ex) { LOGGER.error("Attempt to close RPC client failed", ex); } } ...
#fixed code @Override protected void releaseSub() { if (rpcClient != null) { try { synchronized(this) { try { if (batchSize > 1 && batchEvent.getEvents().size() > 0) { send(bat...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override protected void write(final byte[] bytes, final int offset, final int length, final boolean immediateFlush) { if (socket == null) { if (connector != null && !immediateFail) { connector.latch(); } ...
#fixed code @Override protected void write(final byte[] bytes, final int offset, final int length, final boolean immediateFlush) { if (socket == null) { if (reconnector != null && !immediateFail) { reconnector.latch(); } if...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testFlush() throws IOException { final OutputStream out = EasyMock.createMock(OutputStream.class); out.flush(); // expect the flush to come through to the mocked OutputStream out.close(); replay(out); final ...
#fixed code @Test public void testFlush() throws IOException { final OutputStream out = EasyMock.createMock(OutputStream.class); out.flush(); // expect the flush to come through to the mocked OutputStream out.close(); replay(out); final Logger...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private static void copyFile(final File source, final File destination) throws IOException { if (!destination.exists()) { destination.createNewFile(); } FileChannel srcChannel = null; FileChannel destChannel = null; t...
#fixed code private static void copyFile(final File source, final File destination) throws IOException { if (!destination.exists()) { destination.createNewFile(); } FileChannel srcChannel = null; FileChannel destChannel = null; FileInp...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void forcedLog(String fqcn, Priority level, Object message, Throwable t) { org.apache.logging.log4j.Level lvl = org.apache.logging.log4j.Level.toLevel(level.toString()); logger.log(null, fqcn, lvl, new ObjectMessage(message), t); } ...
#fixed code public void forcedLog(String fqcn, Priority level, Object message, Throwable t) { org.apache.logging.log4j.Level lvl = org.apache.logging.log4j.Level.toLevel(level.toString()); Message msg = message instanceof Message ? (ObjectMessage) message : new ObjectMess...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void addScript(Script script) { ScriptEngine engine = manager.getEngineByName(script.getLanguage()); if (engine == null) { logger.error("No ScriptEngine found for language " + script.getLanguage()); } if (engine.getFact...
#fixed code public void addScript(Script script) { ScriptEngine engine = manager.getEngineByName(script.getLanguage()); if (engine == null) { logger.error("No ScriptEngine found for language " + script.getLanguage() + ". Available languages are: " + ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(String[] args) throws Exception { System.setProperty("Log4jContextSelector", AsyncLoggerContextSelector.class.getName()); Logger logger = LogManager.getLogger(); if (!(logger instanceof AsyncLogger)) { throw n...
#fixed code public static void main(String[] args) throws Exception { System.setProperty("Log4jContextSelector", AsyncLoggerContextSelector.class.getName()); Logger logger = LogManager.getLogger(); if (!(logger instanceof AsyncLogger)) { throw new Ill...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testAppender() throws Exception { final Logger logger = ctx.getLogger(); logger.debug("This is test message number 1"); Thread.sleep(1500); // Trigger the rollover for (int i = 0; i < 16; ++i) { l...
#fixed code @Test public void testAppender() throws Exception { final Logger logger = ctx.getLogger(); logger.debug("This is test message number 1"); Thread.sleep(1500); // Trigger the rollover for (int i = 0; i < 16; ++i) { logger....
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public String toSerializable(final LogEvent event) { final Message message = event.getMessage(); final Object[] parameters = message.getParameters(); final StringBuilder buffer = prepareStringBuilder(strBuilder); try { ...
#fixed code @Override public String toSerializable(final LogEvent event) { final Message message = event.getMessage(); final Object[] parameters = message.getParameters(); final StringBuilder buffer = getStringBuilder(); // Revisit when 1.3 is out so t...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public boolean hasFilters() { return hasFilters; } #location 2 #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code public boolean hasFilters() { return filters.hasFilters(); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override protected void releaseSub() { if (rpcClient != null) { try { rpcClient.close(); } catch (final Exception ex) { LOGGER.error("Attempt to close RPC client failed", ex); } } ...
#fixed code @Override protected void releaseSub() { if (rpcClient != null) { try { synchronized(this) { try { if (batchSize > 1 && batchEvent.getEvents().size() > 0) { send(bat...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void logToFile() throws Exception { final FileOutputStream fos = new FileOutputStream(LOGFILE, false); fos.flush(); fos.close(); final Logger logger = LogManager.getLogger("org.apache.logging.log4j.test2.Test"); l...
#fixed code @Test public void logToFile() throws Exception { final FileOutputStream fos = new FileOutputStream(LOGFILE, false); fos.flush(); fos.close(); final Logger logger = LogManager.getLogger("org.apache.logging.log4j.test2.Test"); logger....
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public EventRoute getEventRoute(final Level logLevel) { final int remainingCapacity = remainingDisruptorCapacity(); if (remainingCapacity < 0) { return EventRoute.DISCARD; } return asyncEventRouter.getRoute(backg...
#fixed code @Override public EventRoute getEventRoute(final Level logLevel) { final int remainingCapacity = remainingDisruptorCapacity(); if (remainingCapacity < 0) { return EventRoute.DISCARD; } return asyncQueueFullPolicy.getRoute(backgro...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(final String[] args) throws Exception { if (args.length != 4) { usage("Wrong number of arguments."); } final String tcfBindingName = args[0]; final String topicBindingName = args[1]; final Stri...
#fixed code public static void main(final String[] args) throws Exception { final JmsTopicReceiver receiver = new JmsTopicReceiver(); receiver.doMain(args); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testConfig() { final LoggerContext ctx = Configurator.initialize("Test1", "target/test-classes/log4j2-sdfilter.xml"); final Configuration config = ctx.getConfiguration(); final Filter filter = config.getFilter(); ass...
#fixed code @Test public void testConfig() { final Configuration config = context.getConfiguration(); final Filter filter = config.getFilter(); assertNotNull("No StructuredDataFilter", filter); assertTrue("Not a StructuredDataFilter", filter instanceof...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @BeforeClass public static void setUpClass() throws Exception { // TODO: refactor PluginManager.decode() into this module? pluginCategories = new ConcurrentHashMap<String, ConcurrentMap<String, PluginEntry>>(); final Enumeration<URL> resource...
#fixed code @BeforeClass public static void setUpClass() throws Exception { // TODO: refactor PluginManager.decode() into this module? pluginCategories = new ConcurrentHashMap<String, ConcurrentMap<String, PluginEntry>>(); final Enumeration<URL> resources = Pl...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(String[] args) throws Exception { System.setProperty("Log4jContextSelector", AsyncLoggerContextSelector.class.getName()); Logger logger = LogManager.getLogger(); if (!(logger instanceof AsyncLogger)) { throw n...
#fixed code public static void main(String[] args) throws Exception { System.setProperty("Log4jContextSelector", AsyncLoggerContextSelector.class.getName()); Logger logger = LogManager.getLogger(); if (!(logger instanceof AsyncLogger)) { throw new Ill...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static boolean compare(final Class<?> testClass, final String file1, final String file2) throws IOException { final BufferedReader in1 = new BufferedReader(new FileReader(file1));...
#fixed code public static boolean compare(final Class<?> testClass, final String file1, final String file2) throws IOException { try (final BufferedReader in1 = new BufferedReader(new FileReader(file1)); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void compareLogEvents(final LogEvent orig, final LogEvent changed) { // Ensure that everything but the Mapped Data is still the same Assert.assertEquals("LoggerName changed", orig.getLoggerName(), changed.getLoggerName()); Assert.assertEq...
#fixed code private void compareLogEvents(final LogEvent orig, final LogEvent changed) { // Ensure that everything but the Mapped Data is still the same assertEquals("LoggerName changed", orig.getLoggerName(), changed.getLoggerName()); assertEquals("Marker changed...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testMissingRootLogger() throws Exception { PluginManager.addPackage("org.apache.logging.log4j.test.appender"); final LoggerContext ctx = Configurator.initialize("Test1", "missingRootLogger.xml"); final Logger logger = LogMan...
#fixed code @Test public void testMissingRootLogger() throws Exception { final LoggerContext ctx = context.getContext(); final Logger logger = ctx.getLogger("sample.Logger1"); assertTrue("Logger should have the INFO level enabled", logger.isInfoEnabled()); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static boolean execute(final File source, final File destination, final boolean deleteSource, final int level) throws IOException { if (source.exists()) { final FileInputStream fis = new FileInputStream(source); final FileO...
#fixed code public static boolean execute(final File source, final File destination, final boolean deleteSource, final int level) throws IOException { if (source.exists()) { try (final FileInputStream fis = new FileInputStream(source); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testFlush() throws IOException { final OutputStream out = EasyMock.createMock("out", OutputStream.class); out.flush(); // expect the flush to come through to the mocked OutputStream out.close(); replay(out); ...
#fixed code @Test public void testFlush() throws IOException { final OutputStream out = EasyMock.createMock("out", OutputStream.class); out.flush(); // expect the flush to come through to the mocked OutputStream out.close(); replay(out); try (...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testNoMsg() { final RegexFilter filter = RegexFilter.createFilter(Pattern.compile(".* test .*"), false, null, null); filter.start(); assertTrue(filter.isStarted()); assertSame(Filter.Result.DENY, filter.filter(null, ...
#fixed code @Test public void testNoMsg() throws Exception { final RegexFilter filter = RegexFilter.createFilter(".* test .*", null, false, null, null); filter.start(); assertTrue(filter.isStarted()); assertSame(Filter.Result.DENY, filter.filter(null, ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testThresholds() { final ThresholdFilter filter = ThresholdFilter.createFilter("ERROR", null, null); filter.start(); assertTrue(filter.isStarted()); assertSame(Filter.Result.DENY, filter.filter(null, Level.DEBUG, nul...
#fixed code @Test public void testThresholds() { final ThresholdFilter filter = ThresholdFilter.createFilter(Level.ERROR, null, null); filter.start(); assertTrue(filter.isStarted()); assertSame(Filter.Result.DENY, filter.filter(null, Level.DEBUG, null,...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static Object deserializeStream(final String witness) throws Exception { final FileInputStream fileIs = new FileInputStream(witness); final ObjectInputStream objIs = new ObjectInputStream(fileIs); try { return objIs.readObject(...
#fixed code public static Object deserializeStream(final String witness) throws Exception { try (final ObjectInputStream objIs = new ObjectInputStream(new FileInputStream(witness))) { return objIs.readObject(); } }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testMemMapLocation() throws Exception { final File f = new File(LOGFILE); if (f.exists()) { assertTrue(f.delete()); } assertTrue(!f.exists()); final int expectedFileLength = Integers.ceil...
#fixed code @Test public void testMemMapLocation() throws Exception { final File f = new File(LOGFILE); if (f.exists()) { assertTrue(f.delete()); } assertTrue(!f.exists()); final int expectedFileLength = Integers.ceilingNex...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testAppender() throws Exception { for (int i=0; i < 100; ++i) { logger.debug("This is test message number " + i); } Thread.sleep(50); final File dir = new File(DIR); assertTrue("Directory not crea...
#fixed code @Test public void testAppender() throws Exception { for (int i=0; i < 100; ++i) { logger.debug("This is test message number " + i); } Thread.sleep(50); final File dir = new File(DIR); assertThat(dir, both(exists()).and(h...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testByName() throws Exception { Configurator.intitalize("-config", null, null); Logger logger = LogManager.getLogger("org.apache.test.TestConfigurator"); LoggerContext ctx = (LoggerContext) LogManager.getContext(false); ...
#fixed code @Test public void testByName() throws Exception { LoggerContext ctx = Configurator.intitalize("-config", null, null); Logger logger = LogManager.getLogger("org.apache.test.TestConfigurator"); Configuration config = ctx.getConfiguration(); a...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testFlush() throws IOException { final OutputStream out = EasyMock.createMock(OutputStream.class); out.flush(); // expect the flush to come through to the mocked OutputStream out.close(); replay(out); final ...
#fixed code @Test public void testFlush() throws IOException { final OutputStream out = EasyMock.createMock(OutputStream.class); out.flush(); // expect the flush to come through to the mocked OutputStream out.close(); replay(out); final Logger...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static boolean execute(final File source, final File destination, final boolean deleteSource, final int level) throws IOException { if (source.exists()) { final FileInputStream fis = new FileInputStream(source); final FileO...
#fixed code public static boolean execute(final File source, final File destination, final boolean deleteSource, final int level) throws IOException { if (source.exists()) { try (final FileInputStream fis = new FileInputStream(source); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void logToFile() throws Exception { final FileOutputStream fos = new FileOutputStream(LOGFILE, false); fos.flush(); fos.close(); final Logger logger = LogManager.getLogger("org.apache.logging.log4j.test2.Test"); l...
#fixed code @Test public void logToFile() throws Exception { final FileOutputStream fos = new FileOutputStream(LOGFILE, false); fos.flush(); fos.close(); final Logger logger = LogManager.getLogger("org.apache.logging.log4j.test2.Test"); logger....
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code EventRoute getEventRoute(final Level logLevel) { final int remainingCapacity = remainingDisruptorCapacity(); if (remainingCapacity < 0) { return EventRoute.DISCARD; } return asyncEventRouter.getRoute(backgroundThreadId, logLev...
#fixed code AsyncLoggerDisruptor(String contextName) { this.contextName = contextName; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testRollingFileAppender() throws Exception { StatusLogger.getLogger().setLevel(Level.TRACE); final Configuration configuration = configure("config-1.2/log4j-RollingFileAppender.properties"); final Appender appender = configuration.getAppender("RFA"...
#fixed code @Test public void testRollingFileAppender() throws Exception { testRollingFileAppender("config-1.2/log4j-RollingFileAppender.properties"); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private static ConcurrentMap<String, ConcurrentMap<String, PluginType>> decode(final ClassLoader loader) { Enumeration<URL> resources; try { resources = loader.getResources(PATH + FILENAME); } catch (final IOException ioe) { ...
#fixed code private static ConcurrentMap<String, ConcurrentMap<String, PluginType>> decode(final ClassLoader loader) { Enumeration<URL> resources; try { resources = loader.getResources(PATH + FILENAME); } catch (final IOException ioe) { LOG...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code static void reportResult(final String file, final String name, final Histogram histogram) throws IOException { final String result = createSamplingReport(name, histogram); println(result); if (file != null) { final FileWr...
#fixed code static void reportResult(final String file, final String name, final Histogram histogram) throws IOException { final String result = createSamplingReport(name, histogram); println(result); if (file != null) { final FileWriter w...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private static OutputStream getOutputStream(final boolean follow, final Target target) { final PrintStream printStream = target == Target.SYSTEM_OUT ? follow ? new PrintStream(new SystemOutStream()) : System.out : follow ? new PrintStream...
#fixed code private static OutputStream getOutputStream(final boolean follow, final Target target) { final PrintStream printStream = target == Target.SYSTEM_OUT ? follow ? new PrintStream(new SystemOutStream()) : System.out : follow ? new PrintStream(new S...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testLayout() throws Exception { final Map<String, Appender> appenders = this.rootLogger.getAppenders(); for (final Appender appender : appenders.values()) { this.rootLogger.removeAppender(appender); } // ...
#fixed code @Test public void testLayout() throws Exception { final Map<String, Appender> appenders = this.rootLogger.getAppenders(); for (final Appender appender : appenders.values()) { this.rootLogger.removeAppender(appender); } // set up...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private String readContents(final URI uri, final Charset charset) throws IOException { InputStream in = null; try { in = uri.toURL().openStream(); final Reader reader = new InputStreamReader(in, charset); final StringB...
#fixed code private String readContents(final URI uri, final Charset charset) throws IOException { if (charset == null) { throw new IllegalArgumentException("charset must not be null"); } Reader reader = null; try { InputStream in =...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @PluginFactory public static <S extends Serializable> SocketAppender<S> createAppender(@PluginAttr("host") final String host, @PluginAttr("port") final String portNum, @P...
#fixed code @PluginFactory public static <S extends Serializable> SocketAppender<S> createAppender(@PluginAttr("host") final String host, @PluginAttr("port") final String portNum, @PluginA...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void log(final LogEvent event) { counter.incrementAndGet(); try { if (isFiltered(event)) { return; } event.setIncludeLocation(isIncludeLocation()); callAppenders(event); ...
#fixed code public void log(final LogEvent event) { beforeLogEvent(); try { if (!isFiltered(event)) { processLogEvent(event); } } finally { afterLogEvent(); } }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static boolean execute(final File source, final File destination, final boolean deleteSource) throws IOException { if (source.exists()) { final FileInputStream fis = new FileInputStream(source); final FileOutputStream fos =...
#fixed code public static boolean execute(final File source, final File destination, final boolean deleteSource) throws IOException { if (source.exists()) { try (final FileInputStream fis = new FileInputStream(source); final BufferedOut...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testAppender() throws Exception { for (int i=0; i < 100; ++i) { logger.debug("This is test message number " + i); } final File dir = new File(DIR); assertTrue("Directory not created", dir.exists() && dir....
#fixed code @Test public void testAppender() throws Exception { for (int i=0; i < 100; ++i) { logger.debug("This is test message number " + i); } final File dir = new File(DIR); assertThat(dir, both(exists()).and(hasFiles())); final...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testFlush() throws IOException { final OutputStream out = EasyMock.createMock("out", OutputStream.class); out.flush(); // expect the flush to come through to the mocked OutputStream out.close(); replay(out); ...
#fixed code @Test public void testFlush() throws IOException { final OutputStream out = EasyMock.createMock("out", OutputStream.class); out.flush(); // expect the flush to come through to the mocked OutputStream out.close(); replay(out); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override protected void releaseSub() { if (transceiver != null) { try { transceiver.close(); } catch (final IOException ioe) { LOGGER.error("Attempt to clean up Avro transceiver failed", ioe); ...
#fixed code @Override protected void releaseSub() { if (rpcClient != null) { try { rpcClient.close(); } catch (final Exception ex) { LOGGER.error("Attempt to close RPC client failed", ex); } } ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public byte[] toByteArray(final LogEvent event) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ObjectOutputStream oos = new PrivateObjectOutputStream(baos); oos.writeObject(event); } catch (IOException i...
#fixed code public byte[] toByteArray(final LogEvent event) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ObjectOutputStream oos = new PrivateObjectOutputStream(baos); try { oos.writeObject(event); } ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void appendStructuredElements(final StringBuilder buffer, final LogEvent event) { final Message message = event.getMessage(); final boolean isStructured = message instanceof StructuredDataMessage; if (!isStructured && (fieldFormatters!= ...
#fixed code private void appendStructuredElements(final StringBuilder buffer, final LogEvent event) { final Message message = event.getMessage(); final boolean isStructured = message instanceof StructuredDataMessage; if (!isStructured && (fieldFormatters!= null &...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testJmsTopicAppenderCompatibility() throws Exception { assertEquals(0, topic.size()); final JmsAppender appender = (JmsAppender) ctx.getRequiredAppender("JmsTopicAppender"); final LogEvent expected = createLogEvent(); ...
#fixed code @Test public void testJmsTopicAppenderCompatibility() throws Exception { final JmsAppender appender = (JmsAppender) ctx.getRequiredAppender("JmsTopicAppender"); final LogEvent expected = createLogEvent(); appender.append(expected); then(ses...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(final String[] args) throws Exception { if (args.length != 4) { usage("Wrong number of arguments."); } final String qcfBindingName = args[0]; final String queueBindingName = args[1]; final Stri...
#fixed code public static void main(final String[] args) throws Exception { final JmsQueueReceiver receiver = new JmsQueueReceiver(); receiver.doMain(args); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testConfig() { final LoggerContext ctx = Configurator.initialize("Test1", "target/test-classes/log4j2-mapfilter.xml"); final Configuration config = ctx.getConfiguration(); final Filter filter = config.getFilter(); as...
#fixed code @Test public void testConfig() { final Configuration config = context.getConfiguration(); final Filter filter = config.getFilter(); assertNotNull("No MapFilter", filter); assertTrue("Not a MapFilter", filter instanceof MapFilter); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testMemMapExtendsIfNeeded() throws Exception { final File f = new File(LOGFILE); if (f.exists()) { assertTrue(f.delete()); } assertTrue(!f.exists()); final Logger log = LogManager.getLogger(); ...
#fixed code @Test public void testMemMapExtendsIfNeeded() throws Exception { final File f = new File(LOGFILE); if (f.exists()) { assertTrue(f.delete()); } assertTrue(!f.exists()); final Logger log = LogManager.getLogger(); ...
Below is the vulnerable code, please generate the patch based on the following information.