output
stringlengths
64
73.2k
input
stringlengths
208
73.3k
instruction
stringclasses
1 value
#fixed code @SuppressWarnings( "ConstantConditions" ) @Test public void shouldHandleNullAuthToken() throws Throwable { // Given AuthToken token = null; try ( Driver driver = GraphDatabase.driver( neo4j.address(), token ) ) { Session...
#vulnerable code @SuppressWarnings( "ConstantConditions" ) @Test public void shouldHandleNullAuthToken() throws Throwable { // Given AuthToken token = null; Driver driver = GraphDatabase.driver( neo4j.address(), token); Session session = drive...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test void shouldContainTimeInformation() { // Given ResultSummary summary = session.run( "UNWIND range(1,1000) AS n RETURN n AS number" ).consume(); // Then assertThat( summary.resultAvailableAfter( TimeUnit.MILLISECONDS ), greaterTha...
#vulnerable code @Test void shouldContainTimeInformation() { // Given ResultSummary summary = session.run( "UNWIND range(1,1000) AS n RETURN n AS number" ).consume(); // Then ServerVersion serverVersion = ServerVersion.version( summary.server().v...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void shouldNotAllowNewTxWhileOneIsRunning() throws Throwable { // Given when( mock.isOpen() ).thenReturn( true ); sess.beginTransaction(); // Expect exception.expect( ClientException.class ); // When ...
#vulnerable code @Test public void shouldNotAllowNewTxWhileOneIsRunning() throws Throwable { // Given Connection mock = mock( Connection.class ); when( mock.isOpen() ).thenReturn( true ); InternalSession sess = new InternalSession( mock ); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void shouldNotPutBackPurgedConnection() throws IOException, InterruptedException, StubServer.ForceKilled { // Given StubServer server = StubServer.start( resource( "not_reuse_connection.script" ), 9001 ); //START servers S...
#vulnerable code @Test public void shouldNotPutBackPurgedConnection() throws IOException, InterruptedException, StubServer.ForceKilled { // Given StubServer server = StubServer.start( resource( "not_reuse_connection.script" ), 9001 ); //START servers ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static void saveX509Cert( Certificate[] certs, File certFile ) throws GeneralSecurityException, IOException { try ( BufferedWriter writer = new BufferedWriter( new FileWriter( certFile ) ) ) { for ( Certificate cert : certs ) ...
#vulnerable code public static void saveX509Cert( Certificate[] certs, File certFile ) throws GeneralSecurityException, IOException { BufferedWriter writer = new BufferedWriter( new FileWriter( certFile ) ); for ( Certificate cert : certs ) { Str...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void shouldKnowSessionIsClosed() throws Throwable { // Given try( Driver driver = GraphDatabase.driver( neo4j.address() ) ) { Session session = driver.session(); // When session.close(); ...
#vulnerable code @Test public void shouldKnowSessionIsClosed() throws Throwable { // Given Driver driver = GraphDatabase.driver( neo4j.address() ); Session session = driver.session(); // When session.close(); // Then asse...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void shouldBeAbleToUseSessionAgainWhenTransactionIsClosed() throws Throwable { // Given when( mock.isOpen() ).thenReturn( true ); sess.beginTransaction().close(); // When sess.run( "whatever" ); // Then ...
#vulnerable code @Test public void shouldBeAbleToUseSessionAgainWhenTransactionIsClosed() throws Throwable { // Given Connection mock = mock( Connection.class ); when( mock.isOpen() ).thenReturn( true ); InternalSession sess = new InternalSession(...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void shouldNotPutBackPurgedConnection() throws IOException, InterruptedException, StubServer.ForceKilled { // Given StubServer server = StubServer.start( "not_reuse_connection.script", 9001 ); //START servers StubServer re...
#vulnerable code @Test public void shouldNotPutBackPurgedConnection() throws IOException, InterruptedException, StubServer.ForceKilled { // Given StubServer server = StubServer.start( "not_reuse_connection.script", 9001 ); //START servers StubSer...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void shouldNotCloseSessionFactoryMultipleTimes() { SessionFactory sessionFactory = sessionFactoryMock(); InternalDriver driver = newDriver( sessionFactory ); assertNull( await( driver.closeAsync() ) ); assertNull( await( d...
#vulnerable code @Test public void shouldNotCloseSessionFactoryMultipleTimes() { SessionFactory sessionFactory = sessionFactoryMock(); InternalDriver driver = newDriver( sessionFactory ); assertNull( getBlocking( driver.closeAsync() ) ); assertNu...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test void shouldSendReadAccessModeInStatementMetadata() throws Exception { StubServer server = StubServer.start( "hello_run_exit_read.script", 9001 ); try ( Driver driver = GraphDatabase.driver( "bolt://localhost:9001", INSECURE_CONFIG ); ...
#vulnerable code @Test void shouldSendReadAccessModeInStatementMetadata() throws Exception { StubServer server = StubServer.start( "hello_run_exit_read.script", 9001 ); Config config = Config.builder() .withoutEncryption() .build(...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void shouldExplainConnectionError() throws Throwable { // Expect exception.expect( ClientException.class ); exception.expectMessage( "Unable to connect to 'localhost' on port 7777, ensure the database is running " + ...
#vulnerable code @Test public void shouldExplainConnectionError() throws Throwable { // Expect exception.expect( ClientException.class ); exception.expectMessage( "Unable to connect to 'localhost' on port 7777, ensure the database is running " + ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void shouldBeAbleToOpenTxAfterPreviousIsClosed() throws Throwable { // Given when( mock.isOpen() ).thenReturn( true ); sess.beginTransaction().close(); // When Transaction tx = sess.beginTransaction(); // ...
#vulnerable code @Test public void shouldBeAbleToOpenTxAfterPreviousIsClosed() throws Throwable { // Given Connection mock = mock( Connection.class ); when( mock.isOpen() ).thenReturn( true ); InternalSession sess = new InternalSession( mock ); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void shouldNotPutBackPurgedConnection() throws IOException, InterruptedException, StubServer.ForceKilled { // Given StubServer server = StubServer.start( "not_reuse_connection.script", 9001 ); //START servers StubServer re...
#vulnerable code @Test public void shouldNotPutBackPurgedConnection() throws IOException, InterruptedException, StubServer.ForceKilled { // Given StubServer server = StubServer.start( "not_reuse_connection.script", 9001 ); //START servers StubSer...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override void assertExpectedReadQueryDistribution( Context context ) { Map<String,Long> readQueriesByServer = context.getReadQueriesByServer(); ClusterAddresses clusterAddresses = fetchClusterAddresses( driver ); // expect all followers to se...
#vulnerable code @Override void assertExpectedReadQueryDistribution( Context context ) { Map<String,Long> readQueriesByServer = context.getReadQueriesByServer(); ClusterAddresses clusterAddresses = fetchClusterAddresses( driver ); // before 3.2.0 only re...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void shouldNotPutBackPurgedConnection() throws IOException, InterruptedException, StubServer.ForceKilled { // Given StubServer server = StubServer.start( resource( "not_reuse_connection.script" ), 9001 ); //START servers S...
#vulnerable code @Test public void shouldNotPutBackPurgedConnection() throws IOException, InterruptedException, StubServer.ForceKilled { // Given StubServer server = StubServer.start( resource( "not_reuse_connection.script" ), 9001 ); //START servers ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static Driver driver( URI uri, AuthToken authToken, Config config ) { // Make sure we have some configuration to play with config = config == null ? Config.defaultConfig() : config; return new DriverFactory().newInstance( uri, authToken, co...
#vulnerable code public static Driver driver( URI uri, AuthToken authToken, Config config ) { // Break down the URI into its constituent parts String scheme = uri.getScheme(); BoltServerAddress address = BoltServerAddress.from( uri ); // Make sure we...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void shouldSyncOnRun() throws Throwable { // Given Connection mock = mock( Connection.class ); when( mock.isOpen() ).thenReturn( true ); InternalSession sess = new InternalSession( mock ); // When sess.run(...
#vulnerable code @Test public void shouldSyncOnRun() throws Throwable { // Given Connection mock = mock( Connection.class ); InternalSession sess = new InternalSession( mock ); // When sess.run( "whatever" ); // Then veri...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void shouldLoadCSV() throws Throwable { // Given try( Driver driver = GraphDatabase.driver( neo4j.address() ); Session session = driver.session() ) { String csvFileUrl = createLocalIrisData( session ); ...
#vulnerable code @Test public void shouldLoadCSV() throws Throwable { // Given Driver driver = GraphDatabase.driver( neo4j.address() ); Session session = driver.session(); String csvFileUrl = createLocalIrisData( session ); // When ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void shouldNotAllowMoreStatementsInSessionWhileConnectionClosed() throws Throwable { // Given when( mock.isOpen() ).thenReturn( false ); // Expect exception.expect( ClientException.class ); // When sess.ru...
#vulnerable code @Test public void shouldNotAllowMoreStatementsInSessionWhileConnectionClosed() throws Throwable { // Given Connection mock = mock( Connection.class ); when( mock.isOpen() ).thenReturn( false ); InternalSession sess = new InternalS...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void shouldNotAllowNewTxWhileOneIsRunning() throws Throwable { // Given when( mock.isOpen() ).thenReturn( true ); sess.beginTransaction(); // Expect exception.expect( ClientException.class ); // When ...
#vulnerable code @Test public void shouldNotAllowNewTxWhileOneIsRunning() throws Throwable { // Given Connection mock = mock( Connection.class ); when( mock.isOpen() ).thenReturn( true ); InternalSession sess = new InternalSession( mock ); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static void loadX509Cert( File certFile, KeyStore keyStore ) throws GeneralSecurityException, IOException { try ( BufferedInputStream inputStream = new BufferedInputStream( new FileInputStream( certFile ) ) ) { CertificateFactory certFac...
#vulnerable code public static void loadX509Cert( File certFile, KeyStore keyStore ) throws GeneralSecurityException, IOException { BufferedInputStream inputStream = new BufferedInputStream( new FileInputStream( certFile ) ); CertificateFactory certFactory = Certific...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static void loadX509Cert( File certFile, KeyStore keyStore ) throws GeneralSecurityException, IOException { try ( BufferedInputStream inputStream = new BufferedInputStream( new FileInputStream( certFile ) ) ) { CertificateFactory certFac...
#vulnerable code public static void loadX509Cert( File certFile, KeyStore keyStore ) throws GeneralSecurityException, IOException { BufferedInputStream inputStream = new BufferedInputStream( new FileInputStream( certFile ) ); CertificateFactory certFactory = Certific...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test void shouldNotSendWriteAccessModeInStatementMetadata() throws Exception { StubServer server = StubServer.start( "hello_run_exit.script", 9001 ); try ( Driver driver = GraphDatabase.driver( "bolt://localhost:9001", INSECURE_CONFIG ); ...
#vulnerable code @Test void shouldNotSendWriteAccessModeInStatementMetadata() throws Exception { StubServer server = StubServer.start( "hello_run_exit.script", 9001 ); Config config = Config.builder() .withoutEncryption() .build()...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void load() throws IOException { if ( !knownHosts.exists() ) { return; } assertKnownHostFileReadable(); try ( BufferedReader reader = new BufferedReader( new FileReader( knownHosts ) ) ) { S...
#vulnerable code private void load() throws IOException { if ( !knownHosts.exists() ) { return; } assertKnownHostFileReadable(); BufferedReader reader = new BufferedReader( new FileReader( knownHosts ) ); String line; ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test @SuppressWarnings( "unchecked" ) public void connectSendsInit() { String userAgent = "agentSmith"; ConnectionSettings settings = new ConnectionSettings( basicAuthToken(), userAgent ); RecordingSocketConnector connector = new Recording...
#vulnerable code @Test @SuppressWarnings( "unchecked" ) public void connectSendsInit() { String userAgent = "agentSmith"; ConnectionSettings settings = new ConnectionSettings( basicAuthToken(), userAgent ); TestSocketConnector connector = new TestSock...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static void saveX509Cert( String certStr, File certFile ) throws IOException { try ( BufferedWriter writer = new BufferedWriter( new FileWriter( certFile ) ) ) { writer.write( BEGIN_CERT ); writer.newLine(); writ...
#vulnerable code public static void saveX509Cert( String certStr, File certFile ) throws IOException { BufferedWriter writer = new BufferedWriter( new FileWriter( certFile ) ); writer.write( BEGIN_CERT ); writer.newLine(); writer.write( certStr ); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void shouldGetHelpfulErrorWhenTryingToConnectToHttpPort() throws Throwable { // Given //the http server needs some time to start up Thread.sleep( 2000 ); try( Driver driver = GraphDatabase.driver( "bolt://localhost:7474", ...
#vulnerable code @Test public void shouldGetHelpfulErrorWhenTryingToConnectToHttpPort() throws Throwable { // Given //the http server needs some time to start up Thread.sleep( 2000 ); Driver driver = GraphDatabase.driver( "bolt://localhost:7474", ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void shouldEstablishTLSConnection() throws Throwable { Config config = Config.build().withEncryptionLevel( Config.EncryptionLevel.REQUIRED ).toConfig(); try( Driver driver = GraphDatabase.driver( URI.create( Neo4jRunner.DEFAULT_URL ), co...
#vulnerable code @Test public void shouldEstablishTLSConnection() throws Throwable { Config config = Config.build().withEncryptionLevel( Config.EncryptionLevel.REQUIRED ).toConfig(); Driver driver = GraphDatabase.driver( URI.create( Neo4jRunner....
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testFields() throws Exception { // GIVEN ResultBuilder builder = new ResultBuilder( "<unknown>", ParameterSupport.NO_PARAMETERS ); builder.keys( new String[]{"k1"} ); builder.record( new Value[]{value(42)} ); R...
#vulnerable code @Test public void testFields() throws Exception { // GIVEN ResultBuilder builder = new ResultBuilder( "<unknown>", ParameterSupport.NO_PARAMETERS ); builder.keys( new String[]{"k1"} ); builder.record( new Value[]{value(42)} ); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void shouldNotPutBackPurgedConnection() throws IOException, InterruptedException, StubServer.ForceKilled { // Given StubServer server = StubServer.start( "not_reuse_connection.script", 9001 ); //START servers StubServer re...
#vulnerable code @Test public void shouldNotPutBackPurgedConnection() throws IOException, InterruptedException, StubServer.ForceKilled { // Given StubServer server = StubServer.start( "not_reuse_connection.script", 9001 ); //START servers StubSer...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void connectThrowsForUnknownAuthToken() { ConnectionSettings settings = new ConnectionSettings( mock( AuthToken.class ) ); RecordingSocketConnector connector = new RecordingSocketConnector( settings ); try { co...
#vulnerable code @Test public void connectThrowsForUnknownAuthToken() { ConnectionSettings settings = new ConnectionSettings( mock( AuthToken.class ) ); TestSocketConnector connector = new TestSocketConnector( settings, insecure(), loggingMock() ); try ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static String read(File file) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8")); String ret = new String(new byte[0], "UTF-8"); String line; while ((line = in.readLine()) != null) { ret +=...
#vulnerable code public static String read(File file) throws IOException { // BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8")); InputStream inStream = new FileInputStream(file); BufferedReader in = new BufferedReader(inputStreamToReader...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static void main(String[] args) { System.out.println("********** Running Sikulix.main"); int dl = RunTime.checkArgs(args); if (dl > -1) { testNumber = dl; } if (RunTime.testing) { rt = RunTime.get(); testNumber = rt.getOptionNum...
#vulnerable code public static void main(String[] args) { System.out.println("********** Running Sikulix.main"); int dl = RunTime.checkArgs(args); if (dl > -1) { testNumber = dl; } if (RunTime.testing) { rt = RunTime.get(); testNumber = rt.getOpt...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static void main(String[] args) { String[] splashArgs = new String[]{ "splash", "#", "#" + Settings.SikuliVersionIDE, "", "#", "#... starting - please wait ..."}; Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run...
#vulnerable code public static void main(String[] args) { String[] splashArgs = new String[]{ "splash", "#", "#" + Settings.SikuliVersionIDE, "", "#", "#... starting - please wait ..."}; Runtime.getRuntime().addShutdownHook(new Thread() { @Override public vo...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public <PSI> Iterator<Match> findAll(PSI target) throws FindFailed { lastMatches = null; Image img = null; String targetStr = target.toString(); if (target instanceof String) { targetStr = targetStr.trim(); } while (true) { try { if (...
#vulnerable code public <PSI> Iterator<Match> findAll(PSI target) throws FindFailed { lastMatches = null; Image img = null; String targetStr = target.toString(); if (target instanceof String) { targetStr = targetStr.trim(); } while (true) { try { ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private int runRuby(File ruFile, String[] stmts, String[] scriptPaths) { int exitCode = 0; String stmt = ""; boolean fromIDE = false; String filename = "<script>"; try { if (null == ruFile) { log(lvl, "runRuby: running statements"); StringBuilder buffer = ne...
#vulnerable code private int runRuby(File ruFile, String[] stmts, String[] scriptPaths) { int exitCode = 0; String stmt = ""; boolean fromIDE = false; String filename = "<script>"; try { if (null == ruFile) { log(lvl, "runRuby: running statements"); StringBuilder buffe...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public ScreenImage capture(Rectangle rect) { Debug.log(3, "ScreenUnion: capture: " + rect); Screen s = Screen.getPrimaryScreen(); Location tl = new Location(rect.getLocation()); for (Screen sx : Screen.screens) { if (sx.contains(tl)) { ...
#vulnerable code @Override public ScreenImage capture(Rectangle rect) { Debug.log(3, "ScreenUnion: capture: " + rect); return Region.create(rect).getScreen().capture(rect); } #location 4 #vulnerability type NULL_DEREFER...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static boolean unpackJar(String jarName, String folderName, boolean del) { jarName = FileManager.slashify(jarName, false); if (!jarName.endsWith(".jar")) { jarName += ".jar"; } if (!new File(jarName).isAbsolute()) { log(-1, "unpackJar: jar pat...
#vulnerable code public static boolean unpackJar(String jarName, String folderName, boolean del) { ZipInputStream in = null; BufferedOutputStream out = null; try { if (del) { FileManager.deleteFileOrFolder(folderName); } in = new ZipInputStream(new Bu...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static void main(String[] args) { String[] splashArgs = new String[]{ "splash", "#", "#" + Settings.SikuliVersionIDE, "", "#", "#... starting - please wait ..."}; Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run...
#vulnerable code public static void main(String[] args) { String[] splashArgs = new String[]{ "splash", "#", "#" + Settings.SikuliVersionIDE, "", "#", "#... starting - please wait ..."}; Runtime.getRuntime().addShutdownHook(new Thread() { @Override public vo...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static void main(String[] args) throws FindFailed { System.out.println("********** Running Sikulix.main"); int dl = RunTime.checkArgs(args, RunTime.Type.API); if (dl > -1 && dl < 999) { testNumber = dl; Debug.on(3); } else { testNumber...
#vulnerable code public static void main(String[] args) throws FindFailed { System.out.println("********** Running Sikulix.main"); int dl = RunTime.checkArgs(args, RunTime.Type.API); if (dl > -1 && dl < 999) { testNumber = dl; Debug.on(3); } else { test...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private boolean checkPatterns(ScreenImage simg) { log(lvl + 1, "update: checking patterns"); if (!observedRegion.isObserving()) { return false; } Finder finder = null; for (String name : eventStates.keySet()) { if (!patternsToCheck()) { c...
#vulnerable code private boolean checkPatterns(ScreenImage simg) { log(lvl + 1, "update: checking patterns"); if (!observedRegion.isObserving()) { return false; } Finder finder = null; for (String name : eventStates.keySet()) { if (!patternsToCheck()) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static void main(String[] args) throws FindFailed { System.out.println("********** Running Sikulix.main"); int dl = RunTime.checkArgs(args, RunTime.Type.API); if (dl > -1 && dl < 999) { testNumber = dl; Debug.on(3); } else { testNumber...
#vulnerable code public static void main(String[] args) throws FindFailed { System.out.println("********** Running Sikulix.main"); int dl = RunTime.checkArgs(args, RunTime.Type.API); if (dl > -1 && dl < 999) { testNumber = dl; Debug.on(3); } else { test...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code <PatternString> Component createTargetComponent(org.sikuli.script.Image img) { JLabel cause = null; JPanel dialog = new JPanel(); dialog.setLayout(new BorderLayout()); if (img.isValid()) { if (!img.isText()) { Image bimage = img.get(false); ...
#vulnerable code <PatternString> Component createTargetComponent(org.sikuli.script.Image img) { JLabel cause = null; JPanel dialog = new JPanel(); dialog.setLayout(new BorderLayout()); if (img.isValid()) { if (!img.isText()) { String rescale = ""; Ima...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private <PSI> Match doFind(PSI ptn, RepeatableFind repeating) throws IOException { Finder f = null; Match m = null; boolean findingText = false; lastFindTime = (new Date()).getTime(); ScreenImage simg; if (repeating != null && repeating._finder != null) ...
#vulnerable code private <PSI> Match doFind(PSI ptn, RepeatableFind repeating) throws IOException { Finder f = null; Match m = null; boolean findingText = false; lastFindTime = (new Date()).getTime(); ScreenImage simg; if (repeating != null && repeating._finder != ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void cleanup() { }
#vulnerable code @Override public void cleanup() { HotkeyManager.getInstance().cleanUp(); keyUp(); mouseUp(0); } #location 3 #vulnerability type NULL_DEREFERENCE
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private Boolean handleImageMissing(Image img, boolean recap) { log(lvl, "handleImageMissing: %s (%s)", img.getName(), (recap?"recapture ":"capture missing ")); ObserveEvent evt = null; FindFailedResponse response = findFailedResponse; if (FindFailedResponse.HAND...
#vulnerable code private Boolean handleImageMissing(Image img, boolean recap) { log(lvl, "handleImageMissing: %s (%s)", img.getName(), (recap?"recapture ":"capture missing ")); FindFailedResponse response = handleFindFailedShowDialog(img, true); if (findFailedResponse.RETRY.eq...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code void findTarget(final String patFilename, final Location initOffset) { Thread thread = new Thread(new Runnable() { @Override public void run() { Region screenUnion = Region.create(0, 0, 1, 1); Finder f = new Finder(_simg, screenUnion); try { f.find(p...
#vulnerable code void paintLoading(Graphics2D g2d) { int w = getWidth(), h = getHeight(); g2d.setColor(new Color(0, 0, 0, 200)); g2d.fillRect(0, 0, w, h); BufferedImage spinner = _loading.getFrame(); g2d.drawImage(spinner, null, w / 2 - spinner.getWidth() / 2, h / 2 - spinner.get...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Deprecated public static boolean addHotkey(String key, int modifiers, HotkeyListener listener) { return Key.addHotkey(key, modifiers, listener); }
#vulnerable code @Deprecated public static boolean addHotkey(String key, int modifiers, HotkeyListener listener) { return HotkeyManager.getInstance().addHotkey(key, modifiers, listener); } #location 3 #vulnerability type NU...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static synchronized RunTime get(Type typ, String[] clArgs) { if (runTime == null) { runTime = new RunTime(); if (null != clArgs) { int debugLevel = checkArgs(clArgs, typ); if (Type.IDE.equals(typ)) { if(debugLevel == -1) { ...
#vulnerable code public static synchronized RunTime get(Type typ, String[] clArgs) { if (runTime == null) { runTime = new RunTime(); if (null != clArgs) { int debugLevel = checkArgs(clArgs, typ); if (Type.IDE.equals(typ)) { if(debugLevel == -1) {...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static void main(String[] args) { String[] splashArgs = new String[]{ "splash", "#", "#" + Settings.SikuliVersionIDE, "", "#", "#... starting - please wait ..."}; Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run...
#vulnerable code public static void main(String[] args) { String[] splashArgs = new String[]{ "splash", "#", "#" + Settings.SikuliVersionIDE, "", "#", "#... starting - please wait ..."}; Runtime.getRuntime().addShutdownHook(new Thread() { @Override public vo...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static int isUrlUseabel(URL aURL) { HttpURLConnection conn = null; try { // HttpURLConnection.setFollowRedirects(false); if (getProxy() != null) { conn = (HttpURLConnection) aURL.openConnection(getProxy()); } else { conn = (HttpURLConnection...
#vulnerable code public static int isUrlUseabel(URL aURL) { try { // HttpURLConnection.setFollowRedirects(false); HttpURLConnection con = (HttpURLConnection) aURL.openConnection(); // con.setInstanceFollowRedirects(false); con.setRequestMethod("HEAD"); int retval = con.getRe...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static int checkArgs(String[] args, Type typ) { int debugLevel = -99; boolean runningScriptsWithIDE = false; List<String> options = new ArrayList<String>(); options.addAll(Arrays.asList(args)); for (int n = 0; n < options.size(); n++) { String o...
#vulnerable code public static int checkArgs(String[] args, Type typ) { int debugLevel = -99; List<String> options = new ArrayList<String>(); options.addAll(Arrays.asList(args)); for (int n = 0; n < options.size(); n++) { String opt = options.get(n); if (!opt.s...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void initSikulixOptions() { SikuliRepo = null; Properties prop = new Properties(); String svf = "sikulixversion.txt"; try { InputStream is; is = clsRef.getClassLoader().getResourceAsStream("Settings/" + svf); if (is == null) { t...
#vulnerable code private void initSikulixOptions() { SikuliRepo = null; Properties prop = new Properties(); String svf = "sikulixversion.txt"; try { InputStream is; is = clsRef.getClassLoader().getResourceAsStream("Settings/" + svf); if (is == null) { terminate...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public <PSI> Iterator<Match> findAll(PSI target) throws FindFailed { lastMatches = null; Image img = null; String targetStr = target.toString(); if (target instanceof String) { targetStr = targetStr.trim(); } while (true) { try { if (...
#vulnerable code public <PSI> Iterator<Match> findAll(PSI target) throws FindFailed { lastMatches = null; Image img = null; String targetStr = target.toString(); if (target instanceof String) { targetStr = targetStr.trim(); } while (true) { try { ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { String mName = method.getName(); if ("handleAbout".equals(mName)) { sikulixIDE.doAbout(); } else if ("handlePreferences".equals(mName)) { sikulixIDE.showPrefe...
#vulnerable code @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { String mName = method.getName(); if ("handleAbout".equals(mName)) { SikuliIDE.getInstance().doAbout(); } else if ("handlePreferences".equals(mName)) { S...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void drawScreenFrame(Graphics2D g2d, int scrId) { g2d.setColor(screenFrameColor); g2d.setStroke(strokeScreenFrame); if (screenFrame == null) { screenFrame = Screen.getBounds(scrId); Rectangle ubound = scrOCP.getBounds(); screenFrame.x -= ub...
#vulnerable code private void drawScreenFrame(Graphics2D g2d, int scrId) { Rectangle rect = Screen.getBounds(scrId); Rectangle ubound = (new ScreenUnion()).getBounds(); g2d.setColor(screenFrameColor); g2d.setStroke(strokeScreenFrame); rect.x -= ubound.x; rect.y -= ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static boolean unzip(File fZip, File fTarget) { String fpZip = null; String fpTarget = null; log(lvl, "unzip: from: %s\nto: %s", fZip, fTarget); try { fpZip = fZip.getCanonicalPath(); if (!new File(fpZip).exists()) { throw new IOExcept...
#vulnerable code public static boolean unzip(File fZip, File fTarget) { String fpZip = null; String fpTarget = null; try { fpZip = fZip.getCanonicalPath(); if (!fZip.exists()) { log(-1, "unzip: source not found:\n%s", fpZip); return false; } ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Deprecated public static boolean removeHotkey(char key, int modifiers) { return Key.removeHotkey(key, modifiers); }
#vulnerable code @Deprecated public static boolean removeHotkey(char key, int modifiers) { return HotkeyManager.getInstance().removeHotkey(key, modifiers); } #location 3 #vulnerability type NULL_DEREFERENCE
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public <PSI> Match wait(PSI target, double timeout) throws FindFailed { lastMatch = null; FindFailed shouldAbort = null; RepeatableFind rf = new RepeatableFind(target, null); Image img = rf._image; String targetStr = img.getName(); Boolean response = tru...
#vulnerable code public <PSI> Match wait(PSI target, double timeout) throws FindFailed { RepeatableFind rf; lastMatch = null; //Image img = null; String targetStr = target.toString(); if (target instanceof String) { targetStr = targetStr.trim(); } while (...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static void main(String[] args) throws FindFailed { System.out.println("********** Running Sikulix.main"); int dl = RunTime.checkArgs(args, RunTime.Type.API); if (dl > -1 && dl < 999) { testNumber = dl; Debug.on(3); } else { testNumber...
#vulnerable code public static void main(String[] args) throws FindFailed { System.out.println("********** Running Sikulix.main"); int dl = RunTime.checkArgs(args, RunTime.Type.API); if (dl > -1 && dl < 999) { testNumber = dl; Debug.on(3); } else { test...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void paintComponent(Graphics g) { Graphics2D g2d = (Graphics2D) g; if (getWidth() > 0 && getHeight() > 0) { if (_match != null) { zoomToMatch(); paintSubScreen(g2d); paintMatch(g2d); } else { paintPatternOnly(g2d); } // paintRuler...
#vulnerable code @Override public void paintComponent(Graphics g) { Graphics2D g2d = (Graphics2D) g; if (getWidth() > 0 && getHeight() > 0) { if (_match != null) { zoomToMatch(); paintSubScreen(g2d); paintMatch(g2d); } else { paintPatternOnly(g2d); } paintR...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public <PSI> Iterator<Match> findAll(PSI target) throws FindFailed { lastMatches = null; RepeatableFindAll rf = new RepeatableFindAll(target, null); Image img = rf._image; String targetStr = img.getName(); Boolean response = true; if (!img.isValid() && i...
#vulnerable code public <PSI> Iterator<Match> findAll(PSI target) throws FindFailed { lastMatches = null; Image img = null; String targetStr = target.toString(); if (target instanceof String) { targetStr = targetStr.trim(); } while (true) { try { ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void loadFile(String filename) { log(lvl, "loadfile: %s", filename); filename = FileManager.slashify(filename, false); setSrcBundle(filename + "/"); File script = new File(filename); _editingFile = ScriptRunner.getScriptFile(script); if (_editingFile != null...
#vulnerable code public void loadFile(String filename) { log(lvl, "loadfile: %s", filename); filename = FileManager.slashify(filename, false); setSrcBundle(filename + "/"); File script = new File(filename); _editingFile = ScriptRunner.getScriptFile(script); if (_editingFile !...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void initBeforeLoad(String scriptType, boolean reInit) { String scrType = null; boolean paneIsEmpty = false; log(lvl, "initBeforeLoad: %s", scriptType); if (scriptType == null) { scriptType = Settings.EDEFAULT; paneIsEmpty = true; } if (Settings.EPYT...
#vulnerable code public void initBeforeLoad(String scriptType, boolean reInit) { String scrType = null; boolean paneIsEmpty = false; if (scriptType == null) { scriptType = Settings.EDEFAULT; paneIsEmpty = true; } if (Settings.EPYTHON.equals(scriptType)) { scrType = Set...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static void main(String[] args) throws FindFailed { System.out.println("********** Running Sikulix.main"); int dl = RunTime.checkArgs(args, RunTime.Type.API); if (dl > -1 && dl < 999) { testNumber = dl; Debug.on(3); } else { testNumber...
#vulnerable code public static void main(String[] args) throws FindFailed { System.out.println("********** Running Sikulix.main"); int dl = RunTime.checkArgs(args, RunTime.Type.API); if (dl > -1 && dl < 999) { testNumber = dl; Debug.on(3); } else { test...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public <PSI> Iterator<Match> findAll(PSI target) throws FindFailed { lastMatches = null; Image img = null; String targetStr = target.toString(); if (target instanceof String) { targetStr = targetStr.trim(); } while (true) { try { if (...
#vulnerable code public <PSI> Iterator<Match> findAll(PSI target) throws FindFailed { lastMatches = null; Image img = null; String targetStr = target.toString(); if (target instanceof String) { targetStr = targetStr.trim(); } while (true) { try { ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static int checkArgs(String[] args, Type typ) { int debugLevel = -99; boolean runningScriptsWithIDE = false; List<String> options = new ArrayList<String>(); options.addAll(Arrays.asList(args)); for (int n = 0; n < options.size(); n++) { String o...
#vulnerable code public static int checkArgs(String[] args, Type typ) { int debugLevel = -99; List<String> options = new ArrayList<String>(); options.addAll(Arrays.asList(args)); for (int n = 0; n < options.size(); n++) { String opt = options.get(n); if (!opt.s...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static void main(String[] args) throws FindFailed { System.out.println("********** Running Sikulix.main"); if (args.length > 1 && args[0].toLowerCase().startsWith("runserver")) { if (args[1].toLowerCase().contains("start")) { RunServer.run(nul...
#vulnerable code public static void main(String[] args) throws FindFailed { System.out.println("********** Running Sikulix.main"); int dl = RunTime.checkArgs(args, RunTime.Type.API); if (dl > -1 && dl < 999) { testNumber = dl; Debug.on(3); } else { test...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void drawSelection(Graphics2D g2d) { if (srcx != destx || srcy != desty) { int x1 = (srcx < destx) ? srcx : destx; int y1 = (srcy < desty) ? srcy : desty; int x2 = (srcx > destx) ? srcx : destx; int y2 = (srcy > desty) ? srcy : desty; ...
#vulnerable code private void drawSelection(Graphics2D g2d) { if (srcx != destx || srcy != desty) { int x1 = (srcx < destx) ? srcx : destx; int y1 = (srcy < desty) ? srcy : desty; int x2 = (srcx > destx) ? srcx : destx; int y2 = (srcy > desty) ? srcy : desty; ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Deprecated public static boolean removeHotkey(String key, int modifiers) { return Key.removeHotkey(key, modifiers); }
#vulnerable code @Deprecated public static boolean removeHotkey(String key, int modifiers) { return HotkeyManager.getInstance().removeHotkey(key, modifiers); } #location 3 #vulnerability type NULL_DEREFERENCE
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static void main(String[] args) { Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { log(lvl, "final cleanup"); if (isRunning != null) { try { isRunningFile.close(); ...
#vulnerable code public static void main(String[] args) { Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { log(lvl, "final cleanup"); if (isRunning != null) { try { isRunningFile.close(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static String getFilenameFromImage(BufferedImage img){ TextRecognizer tr = TextRecognizer.getInstance(); if (! PreferencesUser.getInstance().getPrefMoreTextOCR() || tr == null) { return ""; } String text = tr.recognize(img); text = text.replaceA...
#vulnerable code public static String getFilenameFromImage(BufferedImage img){ if (! PreferencesUser.getInstance().getPrefMoreTextOCR()) { return ""; } TextRecognizer tr = TextRecognizer.getInstance(); String text = tr.recognize(img); text = text.replaceAll("\\W"...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code void drawMessage(Graphics2D g2d) { if (promptMsg == null) { return; } g2d.setFont(fontMsg); g2d.setColor(new Color(1f, 1f, 1f, 1)); int sw = g2d.getFontMetrics().stringWidth(promptMsg); int sh = g2d.getFontMetrics().getMaxAscent(); // Rectangle ...
#vulnerable code void drawMessage(Graphics2D g2d) { if (promptMsg == null) { return; } g2d.setFont(fontMsg); g2d.setColor(new Color(1f, 1f, 1f, 1)); int sw = g2d.getFontMetrics().stringWidth(promptMsg); int sh = g2d.getFontMetrics().getMaxAscent(); Rectan...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected static int move(Location loc, Region region) { if (get().device.isSuspended()) { return 0; } if (loc != null) { IRobot r = null; r = loc.getScreen().getRobot(); if (r == null) { return 0; } if (!r.isRemote()) { ...
#vulnerable code protected static int move(Location loc, Region region) { if (get().device.isSuspended()) { return 0; } if (loc != null) { IRobot r = null; r = Screen.getMouseRobot(); if (r == null) { return 0; } if (!r.isRemote()) {...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void update(EventSubject es) { OverlayCapturePrompt ocp = (OverlayCapturePrompt) es; ScreenImage simg = ocp.getSelection(); Screen.closePrompt(); if (simg != null) { try { Thread.sleep(300); } catch (InterruptedException ie...
#vulnerable code @Override public void update(EventSubject es) { OverlayCapturePrompt cp = null; ScreenImage simg = cp.getSelection(); Screen.closePrompt(); if (simg != null) { try { Thread.sleep(300); } catch (InterruptedException ie) { } ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void update(EventSubject es) { OverlayCapturePrompt ocp = (OverlayCapturePrompt) es; ScreenImage simg = ocp.getSelection(); Screen.closePrompt(); if (simg != null) { try { Thread.sleep(300); } catch (InterruptedException ie...
#vulnerable code @Override public void update(EventSubject es) { OverlayCapturePrompt cp = null; ScreenImage simg = cp.getSelection(); Screen.closePrompt(); if (simg != null) { try { Thread.sleep(300); } catch (InterruptedException ie) { } ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static void main(String[] args) throws FindFailed { System.out.println("********** Running Sikulix.main"); int dl = RunTime.checkArgs(args, RunTime.Type.API); if (dl > -1 && dl < 999) { testNumber = dl; Debug.on(3); } else { testNumber...
#vulnerable code public static void main(String[] args) throws FindFailed { System.out.println("********** Running Sikulix.main"); int dl = RunTime.checkArgs(args, RunTime.Type.API); if (dl > -1 && dl < 999) { testNumber = dl; Debug.on(3); } else { test...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public String saveCapture(String name, Region reg) { ScreenImage img; if (reg == null) { img = userCapture("Capture for image " + name); } else { img = capture(reg); } if (img == null) { return null; } else { return img.saveInBund...
#vulnerable code public String saveCapture(String name, Region reg) { ScreenImage img; if (reg == null) { img = userCapture("Capture for image " + name); } else { img = capture(reg); } img.saveInBundle(name); return name; } ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Deprecated public static boolean addHotkey(char key, int modifiers, HotkeyListener listener) { return Key.addHotkey(key, modifiers, listener); }
#vulnerable code @Deprecated public static boolean addHotkey(char key, int modifiers, HotkeyListener listener) { return HotkeyManager.getInstance().addHotkey(key, modifiers, listener); } #location 3 #vulnerability type NULL...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static void main(String[] args) { System.out.println("********** Running Sikulix.main"); int dl = RunTime.checkArgs(args, RunTime.Type.API); if (dl > -1) { testNumber = dl; Debug.on(3); } rt = RunTime.get(); testNumber = rt.getO...
#vulnerable code public static void main(String[] args) { System.out.println("********** Running Sikulix.main"); int dl = RunTime.checkArgs(args, RunTime.Type.API); if (dl > -1) { testNumber = dl; Debug.on(3); } rt = RunTime.get(); testNumber = r...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public boolean reparse() { File temp = null; Element e = this.getDocument().getDefaultRootElement(); if (e.getEndOffset() - e.getStartOffset() == 1) { return true; } if ((temp = reparseBefore()) != null) { if (reparseAfter(temp)) { updateDocumentListeners(); ...
#vulnerable code public boolean reparse() { File temp = FileManager.createTempFile("py"); Element e = this.getDocument().getDefaultRootElement(); if (e.getEndOffset() - e.getStartOffset() == 1) { return true; } try { writeFile(temp.getAbsolutePath()); this.read(new Buffe...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static void runscript(String[] args) { if (isRunningScript) { log(-1, "can run only one script at a time!"); return; } IScriptRunner currentRunner = null; if (args != null && args.length > 1 && args[0].startsWith("-testSetup")) { curr...
#vulnerable code public static void runscript(String[] args) { if (isRunningScript) { log(-1, "can run only one script at a time!"); return; } IScriptRunner currentRunner = null; if (args != null && args.length > 1 && args[0].startsWith("-testSetup")) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public Stream<IdObject<U, List<I>>> get() { try (BufferedReader candidatesReader = new BufferedReader(new FileReader(candidatesPath))) { return candidatesReader.lines().parallel().map(line -> { CharSequence[] tokens = split(li...
#vulnerable code @Override public Stream<IdObject<U, List<I>>> get() { BufferedReader candidatesReader; try { candidatesReader = new BufferedReader(new FileReader(candidatesPath)); } catch (FileNotFoundException ex) { throw new Uncheck...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static <T> List<T> queryObjectListSQL(String poolName, String sql, Class<T> type, Object[] params) { List<T> returnList = null; try { BeanListHandler<T> resultSetHandler = new BeanListHandler<T>(type); returnList = new QueryRunner(DB_CONNECTION_MA...
#vulnerable code public static <T> List<T> queryObjectListSQL(String poolName, String sql, Class<T> type, Object[] params) { List<T> returnList = null; Connection con = null; try { con = DB_CONNECTION_MANAGER.getConnection(poolName); if (con == null) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static List<Object[]> queryGenericObjectArrayListSQL(String poolName, String sql, Object[] params) { List<Object[]> returnList = null; try { ArrayListHandler resultSetHandler = new ArrayListHandler(); // returnList = new QueryRunner().query(con, sq...
#vulnerable code public static List<Object[]> queryGenericObjectArrayListSQL(String poolName, String sql, Object[] params) { List<Object[]> returnList = null; Connection con = null; try { con = DB_CONNECTION_MANAGER.getConnection(poolName); if (con == null) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static int[] executeBatchSQL(String poolName, String sql, Object[][] params) { int[] returnIntArray = null; try { returnIntArray = new QueryRunner(DB_CONNECTION_MANAGER.getDataSource(poolName)).batch(sql, params); } catch (Exception e) { logge...
#vulnerable code public static int[] executeBatchSQL(String poolName, String sql, Object[][] params) { int[] returnIntArray = null; Connection con = null; try { con = DB_CONNECTION_MANAGER.getConnection(poolName); if (con == null) { throw new Connection...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code long getNextSendIndex() { // Fast path if (this.inflights.isEmpty()) { return this.nextIndex; } // Too many in-flight requests. if (this.inflights.size() > this.raftOptions.getMaxReplicatorInflightMsgs()) { retur...
#vulnerable code void installSnapshot() { if (this.state == State.Snapshot) { LOG.warn("Replicator {} is installing snapshot, ignore the new request.", this.options.getPeerId()); this.id.unlock(); return; } boolean doUnlock = t...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code void onRpcReturned(Status status, GetFileResponse response) { this.lock.lock(); try { if (this.finished) { return; } if (!status.isOk()) { // Reset count to make next rpc retry the previous on...
#vulnerable code void sendNextRpc() { this.timer = null; final long offset = requestBuilder.getOffset() + requestBuilder.getCount(); final long maxCount = this.destBuf == null ? raftOptions.getMaxByteCountPerRpc() : Integer.MAX_VALUE; this.requestBuilder ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public boolean connect(final Endpoint endpoint) { final RpcClient rc = this.rpcClient; if (rc == null) { throw new IllegalStateException("Client service is uninitialized."); } if (isConnected(rc, endpoint)) { ...
#vulnerable code @Override public boolean connect(final Endpoint endpoint) { if (this.rpcClient == null) { throw new IllegalStateException("Client service is not inited."); } if (isConnected(endpoint)) { return true; } ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code void onRpcReturned(Status status, GetFileResponse response) { this.lock.lock(); try { if (this.finished) { return; } if (!status.isOk()) { // Reset count to make next rpc retry the previous on...
#vulnerable code void onRpcReturned(Status status, GetFileResponse response) { lock.lock(); try { if (this.finished) { return; } if (!status.isOk()) { // Reset count to make next rpc retry the previous o...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code void onRpcReturned(Status status, GetFileResponse response) { this.lock.lock(); try { if (this.finished) { return; } if (!status.isOk()) { // Reset count to make next rpc retry the previous on...
#vulnerable code void sendNextRpc() { this.timer = null; final long offset = requestBuilder.getOffset() + requestBuilder.getCount(); final long maxCount = this.destBuf == null ? raftOptions.getMaxByteCountPerRpc() : Integer.MAX_VALUE; this.requestBuilder ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void cancel() { this.lock.lock(); try { if (this.finished) { return; } if (this.timer != null) { this.timer.cancel(true); } if (this.rpcCall != nul...
#vulnerable code @Override public void cancel() { lock.lock(); try { if (this.finished) { return; } if (this.timer != null) { this.timer.cancel(true); } if (this.rpcCall != nu...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code void onRpcReturned(Status status, GetFileResponse response) { this.lock.lock(); try { if (this.finished) { return; } if (!status.isOk()) { // Reset count to make next rpc retry the previous on...
#vulnerable code void sendNextRpc() { this.timer = null; final long offset = requestBuilder.getOffset() + requestBuilder.getCount(); final long maxCount = this.destBuf == null ? raftOptions.getMaxByteCountPerRpc() : Integer.MAX_VALUE; this.requestBuilder ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void shutdown(final Closure done) { List<RepeatedTimer> timers = null; this.writeLock.lock(); try { LOG.info("Node {} shutdown, currTerm={} state={}.", getNodeId(), this.currTerm, this.state); if (this.state...
#vulnerable code @Override public void shutdown(final Closure done) { this.writeLock.lock(); try { LOG.info("Node {} shutdown, currTerm={} state={}.", getNodeId(), this.currTerm, this.state); if (this.state.compareTo(State.STATE_SHUTTING) < 0)...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public boolean isConnected(final Endpoint endpoint) { final RpcClient rc = this.rpcClient; return rc != null && isConnected(rc, endpoint); }
#vulnerable code @Override public boolean isConnected(final Endpoint endpoint) { return this.rpcClient.checkConnection(endpoint.toString()); } #location 3 #vulnerability type THREAD_SAFETY_VIOLATION
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code long getNextSendIndex() { // Fast path if (this.inflights.isEmpty()) { return this.nextIndex; } // Too many in-flight requests. if (this.inflights.size() > this.raftOptions.getMaxReplicatorInflightMsgs()) { retur...
#vulnerable code void installSnapshot() { if (this.state == State.Snapshot) { LOG.warn("Replicator {} is installing snapshot, ignore the new request.", this.options.getPeerId()); this.id.unlock(); return; } boolean doUnlock = t...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code void onRpcReturned(Status status, GetFileResponse response) { this.lock.lock(); try { if (this.finished) { return; } if (!status.isOk()) { // Reset count to make next rpc retry the previous on...
#vulnerable code void onRpcReturned(Status status, GetFileResponse response) { lock.lock(); try { if (this.finished) { return; } if (!status.isOk()) { // Reset count to make next rpc retry the previous o...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code void onRpcReturned(Status status, GetFileResponse response) { this.lock.lock(); try { if (this.finished) { return; } if (!status.isOk()) { // Reset count to make next rpc retry the previous on...
#vulnerable code void sendNextRpc() { this.timer = null; final long offset = requestBuilder.getOffset() + requestBuilder.getCount(); final long maxCount = this.destBuf == null ? raftOptions.getMaxByteCountPerRpc() : Integer.MAX_VALUE; this.requestBuilder ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void addLeaderStateListener(final long regionId, final LeaderStateListener listener) { addStateListener(regionId, listener); }
#vulnerable code @Override public void addLeaderStateListener(final long regionId, final LeaderStateListener listener) { checkState(); if (this.storeEngine == null) { throw new IllegalStateException("current node do not have store engine"); } ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void addStateListener(final long regionId, final StateListener listener) { this.stateListenerContainer.addStateListener(regionId, listener); }
#vulnerable code @Override public void addStateListener(final long regionId, final StateListener listener) { checkState(); if (this.storeEngine == null) { throw new IllegalStateException("current node do not have store engine"); } final Re...
Below is the vulnerable code, please generate the patch based on the following information.