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

FileSystemPipe more exits #6740

Merged
merged 35 commits into from
May 22, 2024
Merged

FileSystemPipe more exits #6740

merged 35 commits into from
May 22, 2024

Conversation

tnleeuw
Copy link
Contributor

@tnleeuw tnleeuw commented Apr 29, 2024

No description provided.

@tnleeuw tnleeuw self-assigned this Apr 29, 2024
Copy link
Contributor

@jkosternl jkosternl left a comment

Choose a reason for hiding this comment

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

You've really vacuumed a lot of code, but I think those are good improvements. Thanks Tim!

@@ -63,13 +62,13 @@ public static <F> void checkSource(IBasicFileSystem<F> fileSystem, F source, Fil
public static <F> void prepareDestination(IWritableFileSystem<F> fileSystem, F destination, boolean overwrite, int numOfBackups, FileSystemAction action) throws FileSystemException {
if (fileSystem.exists(destination)) {
if (overwrite) {
log.debug("removing current destination file ["+fileSystem.getCanonicalName(destination)+"]");
log.debug("removing current destination file [{}]", fileSystem.getCanonicalName(destination));
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

Het ophalen van de canonical name kan voor extra compute zorgen bij sommige fs impl.

Suggested change
log.debug("removing current destination file [{}]", fileSystem.getCanonicalName(destination));
log.debug("removing current destination file [{}]", () -> fileSystem.getCanonicalName(destination));

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Dat kan niet, want fileSystem.getCanonicalName(x) kan een exception gooien.

Het zou dan dit moeten worden (Wat de log ook veiliger maakt, natuurlijk):

Suggested change
log.debug("removing current destination file [{}]", fileSystem.getCanonicalName(destination));
log.debug("removing current destination file [{}]", ()-> {
try {
return fileSystem.getCanonicalName(destination);
} catch (FileSystemException e) {
return "<Cannot get canonical name for destination file>";
}
});

Eigenlijk is dit wel een issue. Want ik zie dat er verschillende exceptions zijn, waar we deze method ook gebruiken. Dan gaan we straks fouten verbergen met een fout uit deze method... Dat is niet goed.

Ik ga hier wat meer structureels aan doen misschien, een method getNameSafe() of zoiets.

@@ -109,13 +109,18 @@ public OutputStream appendFile(Path f) throws IOException {

@Override
public Message readFile(Path f, String charset) throws FileSystemException {
if (!f.toFile().exists()) {
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

Suggested change
if (!f.toFile().exists()) {
if (!Files.exists(p)) {

?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

f, of p?

Comment on lines 54 to 55
@Override
void close() throws SenderException;
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

Ik heb ooit #5045 aangemaakt om open/close te vervangen door start en stop. Mocht een pipe/sender dan zelf toch nog AutoCloseable willen implementeren dan kan dat maar het moet niet een verplichting zijn.

Copy link
Sponsor Member

Choose a reason for hiding this comment

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

En wil je deze AutoClosable nog weghalen of...?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ik vind eigenlijk de AutoClosable of een sender nog steeds wel logisch, maar nu weggehaald, zie commit:
cbd3334

* @param f File for which to try to get canonical name
* @return Either the canonical name of the file, or an error.
*/
default String getCanonicalNameOrError(F f) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
default String getCanonicalNameOrError(F f) {
default String getCanonicalNameOrErrorMessage(F f) {

Otherwise it might suggest that it gives a canonical name or throws an error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ben ik met je eens, die twijfel had ik ook. Maar dit is wel heel lang. Ik dacht aan getCanonicalNameForLog() maar het is niet alleen voor logging, ook voor error messages, dus dat denkt het ook niet.
Eigenlijk vind ik alle namen voor deze method lelijk. Ik houd me open voor betere suggesties.

Copy link
Contributor

@jkosternl jkosternl May 14, 2024

Choose a reason for hiding this comment

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

getCanonicalNameSafely perhaps.
Or getCanonicalNameWithoutDisappointingUncleBob 😉

@tnleeuw tnleeuw requested a review from a team May 14, 2024 10:25
Copy link
Sponsor Member

@nielsm5 nielsm5 left a comment

Choose a reason for hiding this comment

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

Ik vind nog steeds de closeable op ISender een beetje vreemd

throw new SenderException(e);
String forwardName = e.getForward().getForwardName();

log.error("Error from FileSystemActor, will return forward name [{}]",forwardName, e);
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

Suggested change
log.error("Error from FileSystemActor, will return forward name [{}]",forwardName, e);
log.info("error from FileSystemActor, will call forward name [{}]",forwardName, e);

Error level is wel heel erg bot.. dat hoeft toch niet?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Je hebt helemaal gelijk. Ik weet niet waarom daar log.error() stond.

Comment on lines 54 to 55
@Override
void close() throws SenderException;
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

En wil je deze AutoClosable nog weghalen of...?

…4933_FileSystemPipeExits

# Conflicts:
#	filesystem/src/main/java/org/frankframework/filesystem/FileSystemActor.java
#	filesystem/src/main/java/org/frankframework/filesystem/LocalFileSystem.java
#	filesystem/src/test/java/org/frankframework/filesystem/FileSystemActorTest.java
#	filesystem/src/test/java/org/frankframework/filesystem/LocalFileSystemActorTest.java
Copy link

sonarcloud bot commented May 22, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
58.4% Coverage on New Code (required ≥ 65%)
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarCloud

Catch issues before they fail your Quality Gate with our IDE extension SonarLint

@@ -1,5 +1,5 @@
/*
Copyright 2019 Integration Partners
Copyright 2019, 2024 Integration Partners
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Copyright 2019, 2024 Integration Partners
Copyright 2019, 2024 WeAreFrank!

@nielsm5 nielsm5 merged commit 0929856 into master May 22, 2024
12 of 15 checks passed
@nielsm5 nielsm5 deleted the issue/4933_FileSystemPipeExits branch May 22, 2024 10:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants