whlee21 / functionaljava

Automatically exported from code.google.com/p/functionaljava
0 stars 0 forks source link

StackOverflowError with IterableW.map #16

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Wrap an existing iterable using IterableW.wrap
2. map a function over resulting IterableW

What is the expected output? What do you see instead?
I would expect an iterable of the mapped value.
I get a StackOverflow Error.

What version of the product are you using? On what operating system?
2.20, Linux, Java 

Please provide any additional information below.
The error does not occur if the Iterable is wrapped and mapped in a Stream
instead.
The code below will hopefully reproduce it:

List<Integer> l = new ArrayList<Integer>();
for (int i = 0; i <3000; i++) {
  l.add(i);
}

IterableW<Integer> lw = IterableW.wrap(l);
// Stream<Integer> ls = Stream.iterableStream(l);

IterableW<String>  strings = lw.map(new F<Integer, String> () {
// Stream<String>  strings = ls.map(new F<Integer, String> () {
    @Override
    public String f(Integer arg0) {
      return arg0.toString();
    }
  });               

Original issue reported on code.google.com by missy.a.petty@gmail.com on 19 Nov 2009 at 10:11

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
scala> val l = new java.util.ArrayList[Int]                                     

l: java.util.ArrayList[Int] = []                                                

scala> for(i <- 0 to 3000) l add i                                              

scala> val lw = IterableW.wrap(l)                                               

lw: fj.data.IterableW[Int] = fj.data.IterableW@a96fd2                           

scala> val strings = lw map (new F[Int, String] { def f(arg0: Int) = 
arg0.toString })  
java.lang.StackOverflowError                                                    

        at java.lang.Integer.toString(Integer.java:305)                                
        at java.lang.Integer.toString(Integer.java:118)                                
        at java.lang.String.valueOf(String.java:2931)
        at java.lang.Integer.toString(Integer.java:722)
        at $anon$1.f(<console>:27)
        at $anon$1.f(<console>:27)
        at fj.data.IterableW$2.f(IterableW.java:73)
        at fj.data.IterableW$2.f(IterableW.java:71)
        at fj.data.IterableW$4.f(IterableW.java:101)
        at fj.data.IterableW$4.f(IterableW.java:99)
        at fj.data.Stream.map(Stream.java:253)
        at fj.data.Stream$3._1(Stream.java:255)
        at fj.data.Stream$3._1(Stream.java:253)
        at fj.P1$10._1(P1.java:221)
        at fj.data.Stream$1._1(Stream.java:112)
        at fj.pre.Monoid$1.f(Monoid.java:113)
        at fj.pre.Monoid$1.f(Monoid.java:111)
        at fj.Function$15$1.f(Function.java:237)
        at fj.data.Stream.foldRight(Stream.java:110)
        at fj.data.Stream$1._1(Stream.java:112)
        at fj.pre.Monoid$1.f(Monoid.java:113)
        at fj.pre.Monoid$1.f(Monoid.java:111)
        at fj.Function$15$1.f(Function.java:237)
        at fj.data.Stream.foldRight(Stream.java:110)

Original comment by tonymor...@gmail.com on 29 Jan 2010 at 9:11

GoogleCodeExporter commented 8 years ago
There is a pull request to fix this:
    https://github.com/functionaljava/functionaljava/pull/25

Please vote +1 on github if you need this merged.

Original comment by marc.sie...@gmail.com on 19 Dec 2012 at 7:48