Giter VIP home page Giter VIP logo

Comments (9)

ophiuhus avatar ophiuhus commented on August 16, 2024 1

Ok, now I see, it was refactored a while ago.
Thanks.
But the changes will be available only in master branch, meaning - only for new versions.
You can update your implementation of CollectionResource to not return null but empty collection.

from milton2.

ophiuhus avatar ophiuhus commented on August 16, 2024

Which Java version do you use?
What I see here is
java.lang.NullPointerException: null
at java.base/java.util.ArrayList.addAll(ArrayList.java:702)
Array list throws an error on addAll.
Constructor of ArrayList doesn't use addAll - at least in recent versions of Java.
DeleteHelperImpl doesn't use any addAll calls.
I suspect it might be somewhere inside your CollectionResource implementation

from milton2.

kofemann avatar kofemann commented on August 16, 2024

java 11. Indeed, the constructor doesn't use addAll, but:

    public ArrayList(Collection<? extends E> c) {
        Object[] a = c.toArray();
        if ((size = a.length) != 0) {

Thus, c.toArray() will fail with NPE, if c is a null.

from milton2.

kofemann avatar kofemann commented on August 16, 2024

and if you look at the javadoc, then ist clearly stated:

   /**
     * Constructs a list containing the elements of the specified
     * collection, in the order they are returned by the collection's
     * iterator.
     *
     * @param c the collection whose elements are to be placed into this list
     * @throws NullPointerException if the specified collection is null
     */

from milton2.

ophiuhus avatar ophiuhus commented on August 16, 2024

Yes, I agree with javadoc. But what's confusing me - is the stacktrace
java.lang.NullPointerException: null
at java.base/java.util.ArrayList.addAll(ArrayList.java:702)
Why there is addAll?
I'm trying to reproduce it

List<? extends String> list = new ArrayList<>(null);
        for (String s : list) {
            System.out.println(s);
        }

Here small code
It gives different trace
Exception in thread "main" java.lang.NullPointerException
at java.base/java.util.ArrayList.(ArrayList.java:179)
at Main.main(Main.java:6)
And it throws it exactly at constructor, while in your case it is thrown in the for loop

from milton2.

kofemann avatar kofemann commented on August 16, 2024

we use milton 2.7.3

from milton2.

ophiuhus avatar ophiuhus commented on August 16, 2024

It doesn't reject the fact it fails not on the constructor, but on the addAll method.
Can you check you CollectionResource implementation - the getChildren method - if it executes somewhere addAll?

from milton2.

kofemann avatar kofemann commented on August 16, 2024

In tag 2.7.3 code looks like this:

		} else if (r instanceof CollectionResource) {
			CollectionResource col = (CollectionResource) r;
			List<Resource> list = new ArrayList<Resource>();
			list.addAll(col.getChildren());

https://github.com/miltonio/milton2/blob/2.7.3.0/milton-server-ce/src/main/java/io/milton/http/DeleteHelperImpl.java#LL62-L65C35

from milton2.

Related Issues (20)

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.