-
Notifications
You must be signed in to change notification settings - Fork 266
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
Issue #246 deprecate file replace option, retain minor version #258
Issue #246 deprecate file replace option, retain minor version #258
Conversation
spring-integration-smb/README.md
Outdated
@@ -18,7 +18,7 @@ Put the following block into pom.xml if using Maven: | |||
<dependency> | |||
<groupId>org.springframework.integration</groupId> | |||
<artifactId>spring-integration-smb</artifactId> | |||
<version>1.2.0.RELEASE</version> | |||
<version>1.3.0.RELEASE</version> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need to start a new version at all.
We don't do a breaking change and any new components can be introduced in any version: they are fully not a breaking change.
Plus I think we need to remove this version from this README at all.
It does not reflect the reality of the project.
The actual version is controlled from the gradle.properties
file.
I'm not sure that we can use that value in some placeholder for README: it is fully static content, so it cannot resolve any external variables.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So you want me to remove the documentation on how to add the dependency for a Maven project? Or leave the version as is or change it to something else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think just remove the <version>
is enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok so what version will we be building here then? I need this for my current changes in my services so that I can pick up the latest JCIFS library in this project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The gradle.properties
has this content:
version=1.2.2.BUILD-SNAPSHOT
So, when we release, it is going to be 1.2.2.RELEASE
.
super(remoteFileTemplate); | ||
} | ||
|
||
public SmbMessageHandler(SmbRemoteFileTemplate remoteFileTemplate, FileExistsMode mode) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to disable SmbRemoteFileTemplate
-based ctors for time being.
Just for the case to not encourage end-users to use those deprecated properties!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I understand... you don't want anybody to use SmbRemoteFileTemplate? I'm just following the pattern for FTP channel adapter in some respects...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's OK to use it outside of this SmbMessageHandler
.
The point is that setReplaceFile(true)
has to be called on the SmbSessionFactory
and if we expose a SmbRemoteFileTemplate
-based ctor, that means end-user will have to call that deprecated setReplaceFile()
manually.
If we don't have this kind of ctors, people will just use an existing one and and won't call a deprecated API, because, yeah, it is deprecated.
Does it make sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are extending FileTransferringMessageHandler
so I have to support all the constructors in it... How am I going to do that unless I change SmbRemoteFileTemplate like I first proposed in the other branch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is that?
There is just enough to have a one ctor based on one super or delegating to another super?
We are not forced to implement all the super ctors.
public SmbMessageHandler(SessionFactory<SmbFile> sessionFactory) { | ||
this(new SmbRemoteFileTemplate(sessionFactory)); | ||
SmbSessionFactory smbSessionFactory = (SmbSessionFactory) sessionFactory; | ||
smbSessionFactory.setReplaceFile(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this one throws a deprecation warning, therefore this ctor has to be marked with the @SuppressWarning("deprecation")
.
It is totally fine to use a deprecated API in the library code since we need to retain the current behavior.
What we only need to avoid is to let end-users call those deprecated setters from their code: we are going to remove them in the next version anyway.
|
||
public SmbMessageHandler(SessionFactory<SmbFile> sessionFactory) { | ||
this(new SmbRemoteFileTemplate(sessionFactory)); | ||
SmbSessionFactory smbSessionFactory = (SmbSessionFactory) sessionFactory; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to have a type check here.
There is a CachingSessionFactory
which may wrap an original one. So, we will fail here with class cast exception.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is kinda why I wanted to clean up this code to remove the unneeded flags and go to a major version... this is getting messy now. When you see the latest edits you will understand what I mean...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah...
If you feel so uncomfortable with such a mess, we definitely can look into a new major version.
But that has to go to Spring Integration project already as a module: #254
I just don't want to support two major versions at the same time...
WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah understood,,, I'm working on trying to get this as clean as possible.
@@ -62,7 +62,7 @@ public void prepare() { | |||
smbSessionFactory.setUsername("sambaguest"); | |||
smbSessionFactory.setPassword("sambaguest"); | |||
smbSessionFactory.setShareAndDir("smb-share/"); | |||
//smbSessionFactory.setReplaceFile(true); // deprecated as of 1.3 | |||
//smbSessionFactory.setReplaceFile(true); // deprecated as of 1.2.2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you still keep this code over here?
I really see it only removed altogether.
Having it commented out does not give us too much value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed.
...ration-smb/src/main/java/org/springframework/integration/smb/outbound/SmbMessageHandler.java
Show resolved
Hide resolved
@SuppressWarnings("deprecation") | ||
public SmbMessageHandler(SessionFactory<SmbFile> sessionFactory, FileExistsMode mode) { | ||
super(new SmbRemoteFileTemplate(sessionFactory)); | ||
Assert.isTrue(mode == FileExistsMode.REPLACE, "Only FileExistsMode.REPLACE is supported."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is that?
The mode
is not a session factory responsibility.
This is exactly what FileTransferringMessageHandler
does for us.
What only I would like to see in this ctor is a delegation to the super one like you do now, but with this mode
propagation.
In addition it would be a plus to call setReplaceFile()
if the provided mode is a FileExistsMode.REPLACE
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not trying to argue with you but we can't support any mode other than FileExistsMode.REPLACE, why wouldn't we want to inform the developer that only that mode is supported?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure in your conclusion. Just follow the this.remoteFileTemplate.send(message, this.mode)
code and see how that mode
is used.
There is a logic like in the RemoteFileTemplate
:
if (FileExistsMode.REPLACE.equals(mode)) {
session.write(stream, tempFilePath);
}
else if (FileExistsMode.APPEND.equals(mode)) {
session.append(stream, tempFilePath);
}
And this has nothing to do with an SMB protocol. We just call respective session
method and so on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get that... but to fix this bug replaceFile always has to be true. There are a few ways to fix it, only one is backwards compatible and will not drive a major version change.
- default replaceFile=true in SmbConfig
- remove all instances of replaceFile code in SmbSession so that the existing file deletes as intended on the SMB share in the write and rename methods
- default replaceFile=true in all constructors for SmbMessageHandler
All the code for replaceFile and even useTempFile is redundant now, it predates any of this code for FileExistsMode.
I still don't understand what use case/requirement you are trying to solution for here with this new public SmbMessageHandler(SessionFactory sessionFactory, FileExistsMode mode).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My point is to retain the FileTransferringMessageHandler
functionality as much as possible.
And that one opens for us only if we expose a ctor based on the FileExistsMode
.
There is nothing special to do for the SmbSession
since it supports an APPEND
as is even right now without any changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think your changes are very close to what I would expect as a fix for the issue.
I'll pull it locally today for final review and probably will merge after.
Thank you!
Feel free to look into moving this project as a module to the https://github.com/spring-projects/spring-integration with respective overhaul afterwards for a new major version over there.
Awesome! Let me know when you can do a release build as I am waiting on these changes for my services to use. Thanks! |
Merged as 9ef8e04 after some minor clean ups. I'm going to release that version today. Thank you for contribution, @GregBragg ; looking forward for more! |
@artembilan as discussed in PR #257:
"For the current one I suggest the plan like this:
This way we should nail both birds: have options deprecated and retain the old behavior in both write() and rename()."