Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NpeFix generates an impossible patch, return null in a constructor #8

Open
monperrus opened this issue Oct 8, 2017 · 5 comments
Open

Comments

@monperrus
Copy link
Contributor

Good news, we have a patch in repairnator!

+++ /StreamDefinitionController.java
@@ -379,2 +379,5 @@
 
+			if (StreamDefinitionController.this.streamService == null) {
+				return null;
+			}
 			streamDeploymentStates = StreamDefinitionController.this.streamService

But this patch is impossible, because it is in a constructor, and return null is impossible in a constructor.

@tdurieux
Copy link
Contributor

tdurieux commented Oct 8, 2017

it is probably an error in the patch generator.
I need more info, the complete json result will be useful

@surli
Copy link
Contributor

surli commented Oct 9, 2017

@tdurieux
Copy link
Contributor

tdurieux commented Oct 9, 2017

NPEFix does not generate correctly the patch.
The strategy is a return VOID in a constructor, it means that it has to wrap with an if not null the end of the constructor.

Like this:

+++ /StreamDefinitionController.java
@@ -379,2 +379,5 @@
 
+			if (StreamDefinitionController.this.streamService != null) {
+				streamDeploymentStates = StreamDefinitionController.this.streamService
+			}
-			streamDeploymentStates = StreamDefinitionController.this.streamService

@monperrus
Copy link
Contributor Author

monperrus commented Oct 9, 2017 via email

@tdurieux
Copy link
Contributor

tdurieux commented Oct 9, 2017

True, I forgot that we remove final modifier...

+++ /StreamDefinitionController.java
@@ -379,2 +379,5 @@
 
+			if (StreamDefinitionController.this.streamService != null) {
+				streamDeploymentStates = StreamDefinitionController.this.streamService
+			} else {
+				streamDeploymentStates = null;
+			}
-			streamDeploymentStates = StreamDefinitionController.this.streamService

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants