This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Product Version = NetBeans IDE 7.1 (Build 201112051121) Operating System = Windows XP version 5.1 running on x86 Java; VM; Vendor = 1.7.0_01 Runtime = Java HotSpot(TM) Client VM 21.1-b02 given this portion of code: method1: [...] try { FileInputStream fis = new FileInputStream(encryptedFile); Pair<Integer, byte[]> versionAndKey = readHeader(fis); (x) SecretKeySpec key = new SecretKeySpec(rsaDecrypt(versionAndKey.getValue2()), "AES"); (x) Cipher cipher = Cipher.getInstance("AES"); (x) cipher.init(Cipher.DECRYPT_MODE, key); decryptStream(fis, cipher, new File(decryptedFile)); [...] method2: [...] try { FileInputStream fis = new FileInputStream(encryptedFile); Pair<Integer, byte[]> versionAndKey = readHeader(fis); (x) SecretKeySpec key = new SecretKeySpec(rsaDecrypt(versionAndKey.getValue2()), "AES"); (x) Cipher cipher = Cipher.getInstance("AES"); (x) cipher.init(Cipher.DECRYPT_MODE, key); if (versionAndKey.getValue1() != 2) { [...] - In method1, mark the lines indicated with (x) - Press Alt-Shift-m - name new Method getCipher --> NB asks whether you would replace the duplicate code of method2 too - answer yes --> in method1 these three lines are replaced by Cipher cipher = getCipher(versionAndKey); whilst in method2 it is Cipher cipher; ### Method call is missing. ### -------------------------------------------------------------------------------------------------------------------------- BTW: The automatic introduced method is private Cipher getCipher(Pair<Integer, byte[]> versionAndKey) throws NoSuchAlgorithmException, InvalidKeyException, NoSuchPaddingException { SecretKeySpec key = new SecretKeySpec(rsaDecrypt(versionAndKey.getValue2()), "AES"); Cipher cipher = Cipher.getInstance("AES"); cipher.init(Cipher.DECRYPT_MODE, key); return cipher; } SecretKeySpec needs an array of byte, versionAndKey.getValue2() is the one. Thus refactoring might better result in private Cipher getCipher(byte[]> value2) throws NoSuchAlgorithmException, InvalidKeyException, NoSuchPaddingException { SecretKeySpec key = new SecretKeySpec(rsaDecrypt(value2()), "AES"); Cipher cipher = Cipher.getInstance("AES"); cipher.init(Cipher.DECRYPT_MODE, key); return cipher; } whereas value2 is a derived variable name. Is this feasable? If the refactoring works like this, the developer only needs to change this ugly name.
reproducible
Fixed in NetBeans daily builds, thanks for the report: http://hg.netbeans.org/jet-main/rev/8b5a083160a0
Integrated into 'main-golden', will be available in build *201204260400* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-golden/rev/8b5a083160a0 User: Jan Lahoda <jlahoda@netbeans.org> Log: #206193: introduce method sometimes forgets to invoke the newly created method due to a flag clash - adding a new flag to keep track if the method was or was not already invoked.