Project

General

Profile

« Previous | Next » 

Revision 52518

fix for package name (HTTPWithFileName -> httpfilename and fixed issue on iterator for HTTPWithFileNameCollectorIterable

View differences:

HTTPWithFileNameCollectorIterable.java
1
package eu.dnetlib.data.collector.plugins.HTTPWithFileName;
1
package eu.dnetlib.data.collector.plugins.httpfilename;
2 2

  
3 3
import java.util.ArrayList;
4 4
import java.util.Iterator;
......
53 53
        return new Iterator<String>(){
54 54

  
55 55
            private String last = null;
56
            private boolean exec_next = true;
56 57

  
57 58
            @Override
58 59
            public boolean hasNext() {
60
                if(exec_next){
61
                    try {
62
                        last = queue.poll(waitTime, TimeUnit.SECONDS);
63
                        exec_next = false;
64
                    }catch(InterruptedException e){
65
                        log.warn(String.format("could not find elements to consume for more than %s%s", waitTime, TimeUnit.SECONDS));
66
                        throw new NoSuchElementException(e.getMessage());
67
                    }
68
                }
69

  
59 70
                return !Objects.equals(last, TERMINATOR);
60 71
            }
61 72

  
62 73
            @Override
63 74
            public String next() {
64
                try {
65
                    last = queue.poll(waitTime, TimeUnit.SECONDS);
66
                    if (Objects.equals(last, TERMINATOR)) {
67
                        log.info("found terminator, omg!");
68
                    }
69
                } catch (InterruptedException e) {
70
                    log.warn(String.format("could not find elements to consume for more than %s%s", waitTime, TimeUnit.SECONDS));
71
                    throw new NoSuchElementException(e.getMessage());
72
                }
75
                exec_next = true;
73 76
                return last;
74 77
            }
75 78

  
79
//            @Override
80
//            public boolean hasNext() {
81
//
82
//                return !Objects.equals(last, TERMINATOR);
83
//            }
84
//
85
//            @Override
86
//            public String next() {
87
//                try {
88
//                    last = queue.poll(waitTime, TimeUnit.SECONDS);
89
//                    if (Objects.equals(last, TERMINATOR)) {
90
//                        log.info("found terminator, omg!");
91
//                    }
92
//                } catch (InterruptedException e) {
93
//                    log.warn(String.format("could not find elements to consume for more than %s%s", waitTime, TimeUnit.SECONDS));
94
//                    throw new NoSuchElementException(e.getMessage());
95
//                }
96
//                return last;
97
//            }
98

  
76 99
        };
77 100
    }
78 101

  

Also available in: Unified diff