This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-vfs.git
The following commit(s) were added to refs/heads/master by this push: new 97766ab Fix typo in comment. Raise embedded if into parent if. 97766ab is described below commit 97766abfff4c03ef9b4df839d54e68b20fab9e47 Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Sun Feb 28 12:51:48 2021 -0500 Fix typo in comment. Raise embedded if into parent if. --- .../vfs2/provider/webdav/ExceptionConverter.java | 30 ++++++++++------------ .../vfs2/provider/webdav4/ExceptionConverter.java | 30 ++++++++++------------ .../vfs2/provider/ftp/FtpClientFactory.java | 8 +++--- .../commons/vfs2/impl/DefaultFileMonitorTest.java | 6 ++--- 4 files changed, 33 insertions(+), 41 deletions(-) diff --git a/commons-vfs2-jackrabbit1/src/main/java/org/apache/commons/vfs2/provider/webdav/ExceptionConverter.java b/commons-vfs2-jackrabbit1/src/main/java/org/apache/commons/vfs2/provider/webdav/ExceptionConverter.java index 9361838..7c9caea 100644 --- a/commons-vfs2-jackrabbit1/src/main/java/org/apache/commons/vfs2/provider/webdav/ExceptionConverter.java +++ b/commons-vfs2-jackrabbit1/src/main/java/org/apache/commons/vfs2/provider/webdav/ExceptionConverter.java @@ -46,22 +46,20 @@ public final class ExceptionConverter { if (davExc.hasErrorCondition()) { try { final Element error = davExc.toXml(DomUtil.BUILDER_FACTORY.newDocumentBuilder().newDocument()); - if (DomUtil.matches(error, DavException.XML_ERROR, DavConstants.NAMESPACE)) { - if (DomUtil.hasChildElement(error, "exception", null)) { - final Element exc = DomUtil.getChildElement(error, "exception", null); - if (DomUtil.hasChildElement(exc, "message", null)) { - msg = DomUtil.getChildText(exc, "message", null); - } - if (DomUtil.hasChildElement(exc, "class", null)) { - final Class<?> cl = Class.forName(DomUtil.getChildText(exc, "class", null)); - final Constructor<?> excConstr = cl.getConstructor(new Class[] { String.class }); - if (excConstr != null) { - final Object o = excConstr.newInstance(new Object[] { msg }); - if (o instanceof FileSystemException) { - return (FileSystemException) o; - } else if (o instanceof Exception) { - return new FileSystemException(msg, (Exception) o); - } + if (DomUtil.matches(error, DavException.XML_ERROR, DavConstants.NAMESPACE) && DomUtil.hasChildElement(error, "exception", null)) { + final Element exc = DomUtil.getChildElement(error, "exception", null); + if (DomUtil.hasChildElement(exc, "message", null)) { + msg = DomUtil.getChildText(exc, "message", null); + } + if (DomUtil.hasChildElement(exc, "class", null)) { + final Class<?> cl = Class.forName(DomUtil.getChildText(exc, "class", null)); + final Constructor<?> excConstr = cl.getConstructor(new Class[] { String.class }); + if (excConstr != null) { + final Object o = excConstr.newInstance(new Object[] { msg }); + if (o instanceof FileSystemException) { + return (FileSystemException) o; + } else if (o instanceof Exception) { + return new FileSystemException(msg, (Exception) o); } } } diff --git a/commons-vfs2-jackrabbit2/src/main/java/org/apache/commons/vfs2/provider/webdav4/ExceptionConverter.java b/commons-vfs2-jackrabbit2/src/main/java/org/apache/commons/vfs2/provider/webdav4/ExceptionConverter.java index dfd83c7..54ace5c 100644 --- a/commons-vfs2-jackrabbit2/src/main/java/org/apache/commons/vfs2/provider/webdav4/ExceptionConverter.java +++ b/commons-vfs2-jackrabbit2/src/main/java/org/apache/commons/vfs2/provider/webdav4/ExceptionConverter.java @@ -40,22 +40,20 @@ public final class ExceptionConverter { if (davExc.hasErrorCondition()) { try { final Element error = davExc.toXml(DomUtil.createDocument()); - if (DomUtil.matches(error, DavException.XML_ERROR, DavConstants.NAMESPACE)) { - if (DomUtil.hasChildElement(error, "exception", null)) { - final Element exc = DomUtil.getChildElement(error, "exception", null); - if (DomUtil.hasChildElement(exc, "message", null)) { - msg = DomUtil.getChildText(exc, "message", null); - } - if (DomUtil.hasChildElement(exc, "class", null)) { - final Class<?> cl = Class.forName(DomUtil.getChildText(exc, "class", null)); - final Constructor<?> excConstr = cl.getConstructor(new Class[] { String.class }); - if (excConstr != null) { - final Object o = excConstr.newInstance(new Object[] { msg }); - if (o instanceof FileSystemException) { - return (FileSystemException) o; - } else if (o instanceof Exception) { - return new FileSystemException(msg, (Exception) o); - } + if (DomUtil.matches(error, DavException.XML_ERROR, DavConstants.NAMESPACE) && DomUtil.hasChildElement(error, "exception", null)) { + final Element exc = DomUtil.getChildElement(error, "exception", null); + if (DomUtil.hasChildElement(exc, "message", null)) { + msg = DomUtil.getChildText(exc, "message", null); + } + if (DomUtil.hasChildElement(exc, "class", null)) { + final Class<?> cl = Class.forName(DomUtil.getChildText(exc, "class", null)); + final Constructor<?> excConstr = cl.getConstructor(new Class[] { String.class }); + if (excConstr != null) { + final Object o = excConstr.newInstance(new Object[] { msg }); + if (o instanceof FileSystemException) { + return (FileSystemException) o; + } else if (o instanceof Exception) { + return new FileSystemException(msg, (Exception) o); } } } diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftp/FtpClientFactory.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftp/FtpClientFactory.java index 6d75340..9d8db03 100644 --- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftp/FtpClientFactory.java +++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftp/FtpClientFactory.java @@ -208,11 +208,9 @@ public final class FtpClientFactory { } final Boolean userDirIsRoot = builder.getUserDirIsRoot(fileSystemOptions); - if (workingDirectory != null && (userDirIsRoot == null || !userDirIsRoot.booleanValue())) { - if (!client.changeWorkingDirectory(workingDirectory)) { - throw new FileSystemException("vfs.provider.ftp/change-work-directory.error", - workingDirectory); - } + if ((workingDirectory != null && (userDirIsRoot == null || !userDirIsRoot.booleanValue())) && !client.changeWorkingDirectory(workingDirectory)) { + throw new FileSystemException("vfs.provider.ftp/change-work-directory.error", + workingDirectory); } final Boolean passiveMode = builder.getPassiveMode(fileSystemOptions); diff --git a/commons-vfs2/src/test/java/org/apache/commons/vfs2/impl/DefaultFileMonitorTest.java b/commons-vfs2/src/test/java/org/apache/commons/vfs2/impl/DefaultFileMonitorTest.java index 0f702bd..df9d4ee 100644 --- a/commons-vfs2/src/test/java/org/apache/commons/vfs2/impl/DefaultFileMonitorTest.java +++ b/commons-vfs2/src/test/java/org/apache/commons/vfs2/impl/DefaultFileMonitorTest.java @@ -69,10 +69,8 @@ public class DefaultFileMonitorTest { @After public void tearDown() throws Exception { - if (testFile != null) { - if (!testFile.delete()) { - testFile.deleteOnExit(); - } + if (testFile != null && !testFile.delete()) { + testFile.deleteOnExit(); } }