« first day (1621 days earlier)      last day (3337 days later) » 
03:00 - 17:0017:00 - 00:00

5:44 PM
Im getting a concurrentmodificationexception when I iterate my HashMap Map<String, HashMap> calls = new HashMap<>();
Google says to use an iterator, but is that relevant for hashmaps?
Right now I'm iterating like:
for (String key : calls.keySet()) {
    HashMap<String, Instant> call = calls.get(key);
    Instant callTime = call.get("time");
    Duration between = Duration.between(callTime, now);
    if (between.getSeconds() >= 120) {
        calls.remove(key);
    }
}
 
fge
@SterlingArcher the foreach loop does create an Iterator behind the scenes; and here you remove an entry while iterating
 
Right, is that not how I should do it?
Should I make an array of call keys and remove them outside the iteration?
(off topic this room is very slow for such a huge language, what gives?)
 
@SterlingArcher you lost bro?
 
fge
Well, it's not like professional Java devs have the time, or inclination, to "waste" their time on chats :p
@SterlingArcher that is one possibility and another one is indeed that you use an Iterator instead
 
Thank god I'm a professional ColdFusion developer and have plenty of time to waste xD
 
5:51 PM
I'm a professional Java avoider
 
@fge thanks, I'll try an iterator instead
 
seriously... my industry is Java-everything
 
We're making the CFM to Java switch, so it's about to be java errday here
 
fge
<-- now a professional Java dev, after 5+ years doing Java open source
@SterlingArcher in this case you want to do this:
 
:O more JS people are here.
:hide yo wives!:
 
5:54 PM
it's not the 1st time I come here.
 
fge
final Iterator<String, Map<String, Instant>> iterator = calls.entrySet();
Map.Entry<String, Map<String, Instant>> entry;
Duration duration;
while (iterator.hasNext()) {
    entry = iterator.next();
    duration = Duration.between(entry.getValue().get("time"), now);
    if (duration.getSeconds() >= 120)
        iterator.remove();
}
Hmmyeah, go figure, a lot of people coming/lurking here are actually Java haters
Meh, I like the language and don't care much for haters since generally their reasons are far removed from The Reality Of Things(tm)
 
I dont quite understand the Map.Entry, what's that?
 
fge
@SterlingArcher a Map<X, Y> is really a Set<Map.Entry<X, Y>>
Well, "really" is not the word
 
like an alias?
 
fge
Let's say that this is how you iterate over all the key/value pairs of a Map, and a pair is a Map.Entry
But you can also iterate over the keys or values alon
 
6:00 PM
ohhhhh
neat!
 
fge
Java has no native types like Python's dict, or JavaScript's objects, or many other language's "associative array" types
This is why there is the collection framework
 
That makes sense, I was curious how collection structures worked in java. I like this, but something like a php associative array is easier to type out
 
fge
Sure is
 
Not saying either or is better, just typing wise lol
 
fge
Yeah, I agree, this can be somewhat painful to type... But now more often than not, overusing collections means an abstraction failure and that you had better create your own objects instead
 
6:06 PM
I'm using a collection to imitate a session since twilio does not persist sessions over http post :(
 
@SterlingArcher don't you get a cookie from twilio?
 
fge
Uh, sorry, for me twilio is just some name (heard of it and that's about it)
 
if not a session cookie, then no session id in the html or something?
 
@FlorianMargaine nah, it just sends some parameters in the post
 
@SterlingArcher did you look at the response headers?
 
6:09 PM
Content-Type application/xml;charset=UTF-8
xml headers
 
@SterlingArcher no set-cookie header?
 
I don't see anything about that in the logs
 
not in the logs, in the response headers
 
@fge sorry, twillio is a call api that uses XML to do conference calls, browser to browser voip, etc
brb food
 
@SterlingArcher damn
 
6:16 PM
@FlorianMargaine yeah you said it. So I have to store every call in a HashMap, and use a Scheduled function to remove inactive calls (calls that hangup before the "session" ends) so it doesnt clog itself up
talk about a pita eh?
 
http://www.commitstrip.com/en/2015/04/01/you-can-leave-now/
CommitStrip - Blog relating the daily life of web agencies developers
You can leave now!
CommitStrip
1427912403
 
fge
6:34 PM
@SterlingArcher you may want to have a look at expiringmap
 
@fge reading! Thanks!
 
7:28 PM
Hi
Anyone there ?
 
fge
7:40 PM
Define "there"
 
Sam
It would be better to ask "Are there any active non-lurking users here able to spare a few mins to answer my question(s)?"
 
7:58 PM
active? no. non-lurking? no. able to spare a few minutes? also no... dammit
 
8:26 PM
Hey room@
 
fge
yawn
 
fge
8:50 PM
0
Q: Why does Spliterator<?> defines NONNULL as a characteristic?

fgeThe javadoc of Spliterator (which is basically what is really behind a Stream if I understand things correctly) defines many characeristics which make sense such as SIZED, CONCURRENT, IMMUTABLE etc. But it also defines NONNULL; why? I'd have though that it would be the user's responsibility to ...

 
 
1 hour later…
 
1 hour later…
11:16 PM
hello
can someone help me with this stackoverflow.com/questions/29398203/…
 
11:39 PM
My hibernate many to many mapping isn't working, can anyone take a look at gist.github.com/daniel103/968c9c1996758cc4dde0
 
03:00 - 17:0017:00 - 00:00

« first day (1621 days earlier)      last day (3337 days later) »