« first day (3440 days earlier)      last day (1725 days later) » 

00:00
No one gets sick on Wednesdays. (source)
 
4 hours later…
03:52
reads a book
 
2 hours later…
05:49
Morning~
06:46
Is it possible to have one table having one-to-many relationship with multiple table in hibernate. e.g. Table1 have one-to-many relationship with Table2, Table3, Table4. I will be storing Table1's primary as foreign key in Table2, Table3, Table4.
07:03
Good morning folks!
Good morning
Good morning.
I have some NPE crashes reported from production when a "null object inside an arraylist" is accessed. e.g. obj.getIssueDate(). Fun part is that the line before this code, there is a check that list shouldn't be null or empty, and the object is set null from no where
I found a question, very similar to what I am asking:
https://stackoverflow.com/questions/6557767/how-to-track-an-object-inside-an-arraylist-becoming-null
Can someone help me in ways of debugging ? Because it cannot be reproduced at my end
I just want to get to root cause
Just FYI, arraylist data is set from an API call
so there is involvement of threads. I am using Retrofit
 
1 hour later…
08:24
@NightFury are multiple threads accessing the same arraylist instance?
and what do you mean with the "check that list shouldn't be null or empty"
Hi, I am trying to mock a javax.validator, and it validates an object derived from another object within the method I am testing. How do I mock the validate() function by deeply constructing the object I need to? Here's the gist: gist.github.com/2DSharp/e5c2584fdcdc554fee970aa67bf7d5fc
a difficult question you have there
@Wietlol ^
can you not stub the validator instance?
(and what for class instance is it)
many questions
08:39
@KarelG that's what I am asking. I need to define the mock validator's behavior and hence stub it out.
--> and what for class instance is it
But going about it would require me to pass the exact instance of User which is constructed from UserDTO.
@KarelG Could you clarify what you mean by "what for class instance is it"?
08:53
@KarelG Thank you for reply. I am not sure, but it is possible. Do you know Android?
what's validator. You have defined it somewhere. Which class does it represent
The list is set at one place and accessed by multiple UI elements
@KarelG That's hibernate validator. hibernate.org/validator
@KarelG These are the checks before crashing point about the list
the elements in the list are mandatory initialized before adding to list. But it is null here. It occurred random and very less
3
Q: Why am getting null value from ArrayList after adding value using thread

Amit GargI run the following code multiple time and found that sometime I get "null" from ArrayList. I am not able to understand why this happening with me while I am adding Integer value to array. package com; import java.util.ArrayList; import java.util.List; public class test implements Runnable { ...

This seems to give me hint about using synchronize
@NightFury if that entity is being accessed by other threads, then it is possible that it is not empty during the check, but when executing those two statements, it got cleared.
however instead of sync'ing it, I suggest that .getList returns a copy of the list
then you are using a local variable
final Optional<List<Type>> optList = Optional.ofNullable(invoiceListEntity)
  .map(InvoiceListEntity::getList);
if (optList.isPresent() && !Collections.isEmptyOrNull(optList.get()) {
  ...
}
09:07
@KarelG Thanks for the tips. Let me look into it. Thanks a bunch!
don't forget this essential part: "I suggest that .getList returns a copy of the list"
@Tarun I see no reason why you shouldnt be able to
@KarelG ?
do you have experience with mocking a validator instance, provided by the framework?
(it's an instance derived from annotation)
@NightFury also, you should check if any elements inside the list are null
^ eh solid point. But that's a design error imo
I don't add nulls in my list
09:14
true... neither do I
but my colleagues were using one of my pieces of software and they complained it broke with an NRE (C#'s NPE)
so...
I just went full ham on the validation
and promised to bring cake if they borked it again :D
still no cake
avoiding null is something they should learn a bit more (they agree with me, but just arent familiar enough with the principle of doing it to do it by default)
@Wietlol should pass a class instance
and there, do null check
that is clumsy
the empty check is something I can live with :P
pass a class instance?
oh, you mean adding null checks in the class constructor?
yes
ye... this is C# land
there is a wee tiny bit of a problem
C# loves nulls
lombok comes nicely with @NonNull annotation :D
09:20
and it 80% doesnt even have constructors
not sure if C# has a similar supporting feature
C#8 even has optional null awareness
but the existing language simply rejects it
it is like typescript or kotlin where you know if something is null if there is a question mark behind the type
but half of the language just doesnt support it because it is so extremely tightly coupled to the null concept
on top of which, it only gives you compiler warnings, not even errors
and if you dont have those enabled in your ide, you wont even see anything
and you still get an NRE when it is used
</rant>
but about the javax.validator
@2dsharp what is so special about this validator that you cant just stub it?
he told this chat.stackoverflow.com/transcript/message/48932095#48932095 (of whcih I don't ... understand)
stubbing service objects is a common thing...
I say that, but I dont do heavy unit testing, especially when mocking (or any other variation) is coming to join the party
but I know the concepts of how unit tests should work
if the validator is an interface, and if that instance is passed via the constructor, you have proper loose coupling and inversion of control
you should be able to stub it without problems
there is no immediate reason, derived from the given information, that this validator is an exception to common stubs
I have that understanding, yet I don't have tried to stub an interface that got derived from an annotation
(javax.validator is an interface fyi)
09:27
it doesnt matter if it is derived from annotations
if it is a stub, you dont give a shit
if it is a stub, you pre-define what it should return, independent of whether the object is valid or not
checks my unit testing cheat sheet
yes
> Stubs provide canned answers to calls made during the test, usually not responding at all to anything outside what's programmed in for the test
09:40
/javadoc HttpServletRequest#getparts
@KarelG Sorry, I can't find that method. :(
 
3 hours later…
13:07
@Wietlol Could you gimme an example based on the gist?
the gist is too small for that
how do you get the validator instance?
where do you get it from?
that is what is most important
@Wietlol It's being injected by spring's @Autowire
how?
It gives me an instance of Hibernate validator
I need to see code
code is unambiguous
13:10
@Service
public class AccountService
{
    private final UserRepository repository;
    private final MessageByLocaleService messageByLocaleService;
    private final Validator validator;

    @Autowired
    public AccountService(UserRepository repository, MessageByLocaleService messageByLocaleService, Validator validator)
    {
        this.repository = repository;
        this.messageByLocaleService = messageByLocaleService;
        this.validator = validator;
    }
explanations are not
This is how.
ok, and how do you get the account service in your unit test?
I create an instance of it. I am trying to test the account service.
code?
13:10
hey, that is a different story
@Wietlol AccountService accountService = new AccountService(repository, messageByLocaleService, validator);
and what validator is that one?
@Mock
Validator validator
ah, now it falls out of my scope
in general terms, the validator you use at the construction should be your stub
Or can be created by: Mockito.mock(validator)
13:12
how you get that instance of the stub depends on your unit testing framework
I am using JUnit/Mockito
but because you just invoke the constructor and you have proper inversion of control, your unit test is perfectly capable of defining which validator you want to use
so, what exactly is the problem you are experiencing?
Check the gist, the validator.validate() requires me to pass a User object whereas the service method asks for a UserDTO argument which is used to construct the User object.
I notice that
If I manually create a User object and do something like when(validator.validate(user)).thenReturn(...), this won't be the same instance as the actual object being constructed inside the service method.
How do I mock that out?
13:15
oh, I see
considering it is a stub, it should work on a wildcard
Yea I figured that too, and trying to use mockito's any() method
although, it does appear to be an interesting situation
I would actually perhaps validate the dto
the dto should be the source of truth since that is the input of your method
this is how our stuff works too
we have two validator types
validators that work on dtos (for internal usage)
and validators that work on the input/output models of the api
those are also shared with the client library to do simple checking before sending it to the remote service
 
3 hours later…
15:56
Anyone knows a good deep copy/clone library which is not outdated ? Found a simple library called "Cloning 1.9.2", it works fine with normal objects but throws massive exceptions due to the incompatibility with lambdas
just dont clone?
Im implementing the Prototype-Pattern for a mmorpg server... each item to clone is highly customizable using the ECS... trust me, the easiest way is to clone
trust me, the easiest way is to not clone
the easiest way is using a factory
With code generation... otherwhise thats ton of work
why so?
it would also be a considerable amount of work making all those objects that you want to clone
that would even be more work in many cases
16:04
We actually had a factory, but droped it because there were issues with the ecs and their components... furthermore it didnt worked quite that good with modding support
Soooo why do you hate cloning ? I feel some negative energy in here
cloning is quite often a cause of bad things happening in your application
as is the reason of why you want to clone in the first place
hence why people stopped doing it as well as making/maintaining libraries that do it for you
16:39
"Why do you hate cloning" - "Because cloning is bad"
You might wanna listen to Wietlol though, he's been coding with Java for over 4 decades
16:51
wait what?!?.. 4 decades? JDK 1.0 (released: January 23, 1996)
you never used the pre alpha 0.-1 snapshot prototype version?
what a noob
I thought that was called the "JDK Beta" ;)
similar to touch screens
touch screens are were discovered in 1973 where the people at CERN were using them
they must have used them for ages before that as well but they were only discovered by someone in 1973 when he was like "we must bring this to the market"
I have a touch screen. It's worse than useless. It can't be cleaned :)
I have a touch screen, but it only has one use
to permanently shut down my laptop
17:06
But you're right though. I did not use the pre-released version of Java.. :)
it is also quite difficult to operate
but also difficult to use incorrectly
The other thing I really don't like about touchscreens is the inability to hover over a link
17:22
@Scratte That simple mindset is the exact reason why you should listen to Wietlol.
@d0n.key Did I at any time not?
Well my initial point was that genaray should listen to Wietlol, but as you just questioned Wietlol's over-professionality, I thought I might aswell tell you to listen to him aswell
Ahh.. well. I have yet to find a reference that dates Java back 4 decades. I do remember reading an article about naming Java once, but I can't seem to find it. It also contained the original name for JavaScript.
I was hoping that it would have a better story about the history of Java in general
Just because Java has not been referenced or named for 40 years, doesn't mean Wietlol couldn't have used it for over 4 decades already.
but I havent used Java for 4 decades... at least not according to the gregorian calendar
17:30
That is true. Wikipedia says "James Gosling, Mike Sheridan, and Patrick Naughton initiated the Java language project in June 1991", so maybe one of those had been playing with it for a long time prior and @Wietlol is one of them :)
could have been true
also... on a side note
@geisterfurz007 Java took 5 years before it was initially released, give me a break with Wietlang :p
ahh.. and this is probably the article I read once. "The language was initially called Oak after an oak tree that stood outside Gosling's office. Later the project went by the name Green and was finally renamed Java, from Java coffee, the coffee from Indonesia."
@Wietlol I guarantee that more people would look into it if you called it Weedlang
@Scratte Wait - so Java is technically named after the island Java, so it's not a coincidence that there's both a language and an island with that name?!
Because I would assume that an indonesian coffee named "Java" has something to do with the indonesian island named "Java"
I suppose any Java can be it's own island ;)
 
2 hours later…
19:12
@d0n.key current name proposal is "Kodian"
@Wietlol Are you creating a new programming language?
Awesome <-- You could even call it that :)
ye, but if you are looking for "awesome sql" on google, I dont think you would be able to find any resources explaining how to do sql in that language, now would it?
Not ..yet
So it's a new SQL language?
19:18
no
it is a general purpose language
So I have figured that I can integration test my REST API with Spring's Webmvctest and I can do the same thing with Postman too. Do you guys prefer one over the other?
my preference is no :D
@2dsharp Postman is easier to read
@d0n.key Yea that's what I was thinking. Passing params and seeing json output is easier in postman.
Yeah I just meant the name, but nice to see we're of the same opinion there.
20:19
What is the best method for compressing XML data?
I was looking at this, but there is no Java implementation
 
2 hours later…
21:58
@Cardinal-ReinstateMonica Remove all extra whitespace and ZIP it?
22:16
I'm using setRoot() of FXMLLoader to load an FXML into an AnchorPane. Now I would like to load a new FXML into that same AnchorPane. Is there a way to "unload" the old FXML root from the AnchorPane?

« first day (3440 days earlier)      last day (1725 days later) »