refactoring-ai / predicting-refactoring-ml

Refactoring recommendation via ML
MIT License
28 stars 8 forks source link

Reading empty files #154

Closed jan-gerling closed 4 years ago

jan-gerling commented 4 years ago

In the sixth stress test (#95 ), I found many instances in which we try to read non-existing files.

Examples

/data-collection_worker_4 2020-03-19 15:29:36 ERROR RefactoringAnalyzer:91 Failed to collect commit data for refactored commit: 3511b333dcb4c3589f73d80c1fb46014c1862f8b
java.lang.IllegalArgumentException: No path found in 202e9c02f8bece3c8ebd3e6115c1df436e43a6e1: /dev/null
    at refactoringml.util.JGitUtils.readFileFromGit(JGitUtils.java:52) ~[data-collection-0.0.1-SNAPSHOT-jar-with-dependencies.jar:?]
    at refactoringml.util.JGitUtils.readFileFromGit(JGitUtils.java:62) ~[data-collection-0.0.1-SNAPSHOT-jar-with-dependencies.jar:?]
    at refactoringml.RefactoringAnalyzer.buildRefactoringCommitObject(RefactoringAnalyzer.java:125) ~[data-collection-0.0.1-SNAPSHOT-jar-with-dependencies.jar:?]
    at refactoringml.RefactoringAnalyzer.collectCommitData(RefactoringAnalyzer.java:75) [data-collection-0.0.1-SNAPSHOT-jar-with-dependencies.jar:?]
    at refactoringml.App.processCommit(App.java:211) [data-collection-0.0.1-SNAPSHOT-jar-with-dependencies.jar:?]
    at refactoringml.App.run(App.java:134) [data-collection-0.0.1-SNAPSHOT-jar-with-dependencies.jar:?]
    at refactoringml.RunQueue.processRepository(RunQueue.java:128) [data-collection-0.0.1-SNAPSHOT-jar-with-dependencies.jar:?]
    at refactoringml.RunQueue.processResponse(RunQueue.java:82) [data-collection-0.0.1-SNAPSHOT-jar-with-dependencies.jar:?]
    at refactoringml.RunQueue.run(RunQueue.java:73) [data-collection-0.0.1-SNAPSHOT-jar-with-dependencies.jar:?]
    at refactoringml.RunQueue.main(RunQueue.java:60) [data-collection-0.0.1-SNAPSHOT-jar-with-dependencies.jar:?]
/data-collection_worker_4 2020-03-19 15:31:05 ERROR RefactoringAnalyzer:91 Failed to collect commit data for refactored commit: 15b57deac14f701db29291d24b91361e94e1be5b
java.lang.IllegalArgumentException: No path found in 55dfb1b9df9d8f2826ca1f6bd8015119900310c2: /dev/null
    at refactoringml.util.JGitUtils.readFileFromGit(JGitUtils.java:52) ~[data-collection-0.0.1-SNAPSHOT-jar-with-dependencies.jar:?]
    at refactoringml.util.JGitUtils.readFileFromGit(JGitUtils.java:62) ~[data-collection-0.0.1-SNAPSHOT-jar-with-dependencies.jar:?]
    at refactoringml.RefactoringAnalyzer.buildRefactoringCommitObject(RefactoringAnalyzer.java:125) ~[data-collection-0.0.1-SNAPSHOT-jar-with-dependencies.jar:?]
    at refactoringml.RefactoringAnalyzer.collectCommitData(RefactoringAnalyzer.java:75) [data-collection-0.0.1-SNAPSHOT-jar-with-dependencies.jar:?]
    at refactoringml.App.processCommit(App.java:211) [data-collection-0.0.1-SNAPSHOT-jar-with-dependencies.jar:?]
    at refactoringml.App.run(App.java:134) [data-collection-0.0.1-SNAPSHOT-jar-with-dependencies.jar:?]
    at refactoringml.RunQueue.processRepository(RunQueue.java:128) [data-collection-0.0.1-SNAPSHOT-jar-with-dependencies.jar:?]
    at refactoringml.RunQueue.processResponse(RunQueue.java:82) [data-collection-0.0.1-SNAPSHOT-jar-with-dependencies.jar:?]
    at refactoringml.RunQueue.run(RunQueue.java:73) [data-collection-0.0.1-SNAPSHOT-jar-with-dependencies.jar:?]
    at refactoringml.RunQueue.main(RunQueue.java:60) [data-collection-0.0.1-SNAPSHOT-jar-with-dependencies.jar:?]
mauricioaniche commented 4 years ago

Great! I was sure this could happen, but couldn't think of a case. I'll isolate the case and fix the bug.

mauricioaniche commented 4 years ago

Indeed, this is because RMiner finds a refactoring in a newly introduced class. I refactored the code so that we treat this expected case. Now, if we see this exception again, it will be in a different case (which we should then debug).

jan-gerling commented 4 years ago

@mauricioaniche can we close this issue?

mauricioaniche commented 4 years ago

Yes. Just ran here in a repo, and now, instead of the exceptions, I get a nice log line (and no errors).

test 2020-03-20 12:40:52 INFO  RefactoringAnalyzer:78 Refactoring in a newly introduced file, which we skip: src/main/java/me/prettyprint/cassandra/model/thrift/ThriftSubSliceQuery.java, commit = CommitMetaData{commit=f8ad7a5aa29b297d3f6281a4d061f8dd9da0da4e, commitDate=java.util.GregorianCalendar[time=1284823145000,areFieldsSet=false,areAllFieldsSet=false,lenient=true,zone=sun.util.calendar.ZoneInfo[id="GMT+02:00",offset=7200000,dstSavings=0,useDaylight=false,transitions=0,lastRule=null],firstDayOfWeek=2,minimalDaysInFirstWeek=4,ERA=1,YEAR=2010,MONTH=8,WEEK_OF_YEAR=37,WEEK_OF_MONTH=3,DAY_OF_MONTH=18,DAY_OF_YEAR=261,DAY_OF_WEEK=7,DAY_OF_WEEK_IN_MONTH=3,AM_PM=1,HOUR=5,HOUR_OF_DAY=17,MINUTE=19,SECOND=5,MILLISECOND=0,ZONE_OFFSET=3600000,DST_OFFSET=3600000], commitMessage=Refactor: Extract interface from RangeSlicesQuery, RangeSubSlicesQuery, SuperSlicesQuery, SubSliceQuery and SuperSliceQuery and move them to the api package, commitUrl=@local/repos/hector/f8ad7a5aa29b297d3f6281a4d061f8dd9da0da4e, parentCommit='2d842732e442b87b60edace58ae93a0e628e4486'}, refactoring = Extract Interface  me.prettyprint.hector.api.query.SubSliceQuery from classes [me.prettyprint.cassandra.model.thrift.ThriftSubSliceQuery]