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

Fix incorrect file name regex logic #21

Merged
merged 5 commits into from
Nov 30, 2021
Merged

Conversation

JSpiner
Copy link
Contributor

@JSpiner JSpiner commented Oct 10, 2021

When I run nexus with nexus run, I got the following error.

Caused by: java.io.IOException: Directory '/Users/smith-debug.jspiner/nexus-3.34.1-01-mac/sonatype-work/nexus3/tmp/nexus-extdirect' could not be created
at org.apache.commons.io.FileUtils.openOutputStream(FileUtils.java:2436)
at org.apache.commons.io.FileUtils.writeStringToFile(FileUtils.java:3356)
at org.apache.commons.io.FileUtils.writeStringToFile(FileUtils.java:3305)

My user name is smith.jspiner and file path is /Users/smith.jspiner/nexus-......
But strangely, nexus was trying with /Users/smith-debug.jspiner/nexus-..... 😭

When I checked the source code, there was an error in changing the file name for debug.

I modified the regex logic and added the test code.
Please review it. 🙏

- `getDebugFileName` only checks whether '.js' is in the file name. So the 'john.jspiner' case throws an error.
- The file extension must be at the end of the full path.
@JSpiner
Copy link
Contributor Author

JSpiner commented Oct 14, 2021

@dbradicich @ataylor284 @thejosh00
Hi! Can I ask for a review? 🙏
I am unable to use nexus because of this issue. 😭

private static String getDebugFileName( String file ) {
String result = file.replace( ".js", "-debug.js");
return result;
int extensionIndex = file.lastIndexOf( ".js" );

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

file.replaceFirst(".js$", "-debug.js"); might be a better way to express this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much better! 👍
Applied in 9eb5223


public class CodeFileGeneratorTest {

private String getDebugFileName(String file) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd just make getDebugFileName package protected (no modifier) instead of using reflection to invoke for testing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was confused because I didn't know the test rules of the project, but it's good that I can use protected function. 👍
Applied in 68d3969

Copy link
Member

@dbradicich dbradicich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JSpiner Thanks for pushing up a UT as well :) we are going to be doing a new release to use in nxrm 3.37 soon and would surely like to include this for you after the comments get resolved

@nblair
Copy link
Contributor

nblair commented Oct 18, 2021

Hi @JSpiner - looks like the code is ready for us to merge. Before we can do that, we need to you sign our Contributor License Agreement, found here:

https://sonatypecla.herokuapp.com/sign-cla

Once you're signature is in we can merge and include in the next release - thank you!

@nblair
Copy link
Contributor

nblair commented Oct 18, 2021

Please attach a screenshot of the completed form to a comment on this thread.

Copy link
Member

@dbradicich dbradicich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, I almost forgot the CLA needs to signed prior to accepting the PR, but codewise looks good to me :)

Please see this link https://sonatypecla.herokuapp.com/sign-cla for the CLA, just comment back here when done and we should be able to get merged for next release (earliest release would be 3.37 of nxrm fyi)

edit: nvmd, i see mr blair beat me to it :)

@JSpiner
Copy link
Contributor Author

JSpiner commented Oct 19, 2021

I signed with this github account. ([email protected])
Thank you very much for your help! 🙇‍♂️
스크린샷 2021-10-19 오전 9 19 39

@JSpiner
Copy link
Contributor Author

JSpiner commented Oct 25, 2021

Is there anything more should I do?

@JSpiner
Copy link
Contributor Author

JSpiner commented Nov 30, 2021

@ataylor284 @dbradicich
Hi! Can it be merged?
I can't use Nexus because of this issue. 😭

@Blacktiger Blacktiger merged commit 9bac450 into sonatype:master Nov 30, 2021
@Blacktiger
Copy link
Contributor

Blacktiger commented Nov 30, 2021

Merged, but it won't get included in Nexus Repository until the next release. I'm not sure when that will be but we missed getting this into 3.37 unfortunately. I believe you could also build this locally and replace the jar in your nexus instance while you wait for a new release.

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

Successfully merging this pull request may close these issues.

5 participants