Coder Social home page Coder Social logo

Comments (6)

maddingo avatar maddingo commented on July 18, 2024

Bug reported by @bgmf on issue #4
java.lang.RuntimeException: jcifs.smb.SmbException: The system cannot find the file specified.
at no.uis.nio.smb.SMBDirectoryStream.iterator(SMBDirectoryStream.java:71)
at no.uis.nio.smb.SambaTest.testSamba(SambaTest.java:56)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: jcifs.smb.SmbException: The system cannot find the file specified.
at jcifs.smb.SmbTransport.checkStatus(SmbTransport.java:542)
at jcifs.smb.SmbTransport.send(SmbTransport.java:619)
at jcifs.smb.SmbSession.send(SmbSession.java:242)
at jcifs.smb.SmbTree.send(SmbTree.java:111)
at jcifs.smb.SmbFile.send(SmbFile.java:729)
at jcifs.smb.SmbFile.doFindFirstNext(SmbFile.java:1931)
at jcifs.smb.SmbFile.doEnum(SmbFile.java:1683)
at jcifs.smb.SmbFile.listFiles(SmbFile.java:1660)
at jcifs.smb.SmbFile.listFiles(SmbFile.java:1593)
at no.uis.nio.smb.SMBDirectoryStream.iterator(SMBDirectoryStream.java:61)
... 24 more

from nio-fs-provider.

maddingo avatar maddingo commented on July 18, 2024

@bgmf: Would you like to share your test case that fails?

from nio-fs-provider.

bgmf avatar bgmf commented on July 18, 2024

Of course. Its more or less the same, like in the last case:

    @Test
    public void testSamba() {

        Logger.getLogger("").setLevel(Level.SEVERE);
        Config.registerSmbURLHandler();

        Path remotePath = null;
        try {
            NtlmAuthenticator.setDefault(new NtlmAuthenticator() {
                private NtlmPasswordAuthentication pa = new NtlmPasswordAuthentication("domain", "user", "password");
                @Override
                protected NtlmPasswordAuthentication getNtlmPasswordAuthentication() {
                    return pa;
                }
            });
            remotePath = Paths.get(new URI("smb://address/c$/Android%20Studio/"));
        } catch (URISyntaxException e1) {
            e1.printStackTrace();
        }

        ArrayList<String> fileNames = new ArrayList<>();
        try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(remotePath, new DirectoryStream.Filter<Path>() {
            @Override
            public boolean accept(Path entry) throws IOException {
                return !Files.isSymbolicLink(entry);
            }
        })) {
            for (Path path : directoryStream) {
                fileNames.add(path.toString());
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        System.out.println(fileNames);
    }

This example will fail because of the encoded space character %20. I tried to deal with it in any way, but since we rely on URI, we have no other option then to use the encoding, otherwise we get an malformed URI exception.

from nio-fs-provider.

maddingo avatar maddingo commented on July 18, 2024

The merge should fix the issue. I have simplified the test cases. Your use case should be covered. The tricky thing is the inconsistency between URL and URI in how they treat spaces. URI is consistent with itself.

from nio-fs-provider.

bgmf avatar bgmf commented on July 18, 2024

Thumbs up! Works for me.
Tested it with a couple of directories over the net and got no further errors (except for some obvious "Access Denied", when I tried to access "Documents and Settings").
Thank you very much for your effort. If I find anything new, I will report it. ;-)

from nio-fs-provider.

maddingo avatar maddingo commented on July 18, 2024

Thanks for your feedback. I published a SNAPSHOT release to the Sonatype Snapshot Release (https://oss.sonatype.org/content/repositories/snapshots/) with the following coordinates:

<dependency>
<groupId>no.maddin.niofs</groupId>
<artifactId>nio-fs-webdav</artifactId>
<version>2.0.0-SNAPSHOT</version>
</dependency>

I would be happy if you could use this artifact. I am planning on releasing this version by the end of the week, if nothing serious turns up.

from nio-fs-provider.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.