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

demo-bootstrap not working #66

Closed
jerrak opened this issue Apr 27, 2019 · 12 comments

Comments

Projects
None yet
2 participants
@jerrak
Copy link

commented Apr 27, 2019

demo-bootstrap does not work if directory "bootstrap" does not exist in advance. Can be solved by adding something as

	if (config.getBasePath() != null && Files.notExists(config.getBasePath()))
		Files.createDirectories(config.getBasePath());

somewhere around line 120 in ConfigImpl maybe?

@mordechaim

This comment has been minimized.

Copy link
Contributor

commented Apr 29, 2019

I never experienced any issues and cannot reproduce it, in fact the following line:

Files.createDirectories(file.getPath().getParent());

does precisely this. Your solution would fail if the individual file itself has subdirectories, or if it uses an explicit base path.

What's the exact exception? What operating system and update4j version? What command do you use to run the demo?

@jerrak

This comment has been minimized.

Copy link
Author

commented Apr 29, 2019

@jerrak

This comment has been minimized.

Copy link
Author

commented Apr 29, 2019

@mordechaim

This comment has been minimized.

Copy link
Contributor

commented Apr 29, 2019

Hmm.. Looks like the createDirectories() is somehow inconsistent across platforms or JDK versions; where it will normalize the path before creating, thus resulting in bootstrap directory not being created. I can easily circumvent this, but I want to be sure I have a lead.

What's your JDK version?

@jerrak

This comment has been minimized.

Copy link
Author

commented Apr 29, 2019

[meije:~/update4j] jara% java --version
openjdk 12.0.1 2019-04-16
OpenJDK Runtime Environment (build 12.0.1+12)
OpenJDK 64-Bit Server VM (build 12.0.1+12, mixed mode, sharing)

but I think the behaviour was the same on J 11.

@mordechaim

This comment has been minimized.

Copy link
Contributor

commented Apr 29, 2019

Just tested it on JDK 12, will not create redundant directory if it is followed with ../ (i.e. it normalizes it) but demo still won't fail for me (Windows 7 x64).

Could be createTempFile() requires those redundant directories on MacOS?

@mordechaim

This comment has been minimized.

Copy link
Contributor

commented Apr 29, 2019

On Windows (assume directory a does not exist):

C:\Users\User\Desktop> echo $null >> a/file.txt
The system cannot find the path specified.
C:\Users\User\Desktop> echo $null >> a/../file.txt
C:\Users\User\Desktop>

On Linux:

[user@ubuntu ~/Desktop]# touch a/file.txt
touch: a/file.txt: No such file or directory
[user@ubuntu ~/Desktop]# touch a/../file.txt
touch: a/../file.txt: No such file or directory

Clearly this is a system dependent issue. On Unix, creating a file that references a directory, even if it goes back a level, it will fail if that directory does not exist. On Windows this is perfectly legal.

@mordechaim

This comment has been minimized.

Copy link
Contributor

commented Apr 29, 2019

On the other hand, on Windows:

C:\Users\User\Desktop> mkdir a/../b

will create directory b only.

While on Linux:

[user@ubuntu ~/Desktop]# mkdir -p a/../b

creates both a and b.

So the original question remains, why won't Files.createDirectories() implicitly create the bootstrap directory on Linux, since this is how mkdir operates?

@jerrak

This comment has been minimized.

Copy link
Author

commented Apr 30, 2019

Nice one... :-) Well, either createDirectories() is not meant to mimic mkdir 1:1, either the actual implementation has this flaw. Anyway, it might be handy to check for the existence of base path in update4j, I was disappointed when the demo did not work out of the box. (But bravo anyway, this is a nice and handy framework with a lot of work done, including docs and demos!)

@mordechaim

This comment has been minimized.

Copy link
Contributor

commented Apr 30, 2019

Can you confirm this build solves the issue?

Never mind that the business app doesn't start, as explained in #67 .

update4j-1.4.1-SNAPSHOT.zip

@mordechaim

This comment has been minimized.

Copy link
Contributor

commented May 2, 2019

@jerrak Can you please confirm the above?

@jerrak

This comment has been minimized.

Copy link
Author

commented May 3, 2019

Yes, this build solved the issue.

@jerrak jerrak closed this May 3, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.