By Chris on December 13, 2022
We needed our compress files generated from our apps at work and I went the old way using a fileInputStream and a fileoutputStream: private static void compressFileToGzipOldWay(File destinationDir, File fileToCompress) throws IOException { String compressedFilesName = fileToCompress.getName() + “.gz”; File compressedFileDir = new File(destinationDir, compressedFilesName); FileInputStream fis = new FileInputStream(fileToCompress.getName()); FileOutputStream fos = new FileOutputStream(compressedFileDir); […]
Posted in java | Tagged gzip, java |
By Chris on June 17, 2021
In the previous post, we discuss own we change from using mongorepository to using directly mongodb method to access and modify directly the object in db.In this posts we look at code that was deleting with mongorepository and change it to use directly mongodb method with MongoTemplate. Using MongoTemplate is faster and less likely to […]
Posted in java, mongodb, prog, tips | Tagged java, mongodb, MongoRepository, MongoTemplate |
By Chris on June 10, 2021
We had at work a piece of code that was using mongorepository and updating the arrays of the object on a collection instead of using mongodb method directly.The way it was coded had a big issues with concurrency and we were losing update because of it.The problem we had with the way it was updating […]
Posted in java, mongodb, prog, tips | Tagged java, mongodb, MongoRepository, MongoTemplate |
By Chris on May 19, 2021
This is old news, but having work with big bank and insurance companies they tend to stick with the old version of java and they’re underlying libraries, I’ve finally been expose to new ways of testing exception with junit. I use to test exception by adding an expected right after the @Test annotation.@Test(expected = NullpointerException) […]
Posted in java | Tagged assertJ, java, junit, junit4, junit5, mokito, testing |
By Chris on May 12, 2021
We recently added a feature that allowed direct modification on our content for some client vs using the same path (queues) that the batched content is using. Our user were really happy with it, but after our team implemented the new feature, we started having some LazyInitializationException. exception for that problem org.hibernate.LazyInitializationException: could not initialize […]
Posted in java | Tagged Exception, hibernate, java, LazyInitializationException |
By Chris on March 2, 2021
Once upon a time an engineer with years of experience encounter something so basic he doesn’t understand why he didn’t encounter it sooner. This week we had a strange error in our log stating that should have a null values in a map. After some digging in the service where that log was found, it […]
Posted in java | Tagged java, java.util.Map, maps, null |
By Chris on May 20, 2020
I was having that weird error when I was working with mapstruct, turn out that the default java version for mapstruct is java 6. Since our project was in java 11 I was getting the error “Constructor XXX in enum XXX cannot be applied to given types”. My starting config was : <dependencies> <dependency> <groupId>org.mapstruct</groupId> […]
Posted in error, java | Tagged java, java8, mapstruts, maven |
By Chris on October 12, 2014
While trying to remove a element after creating a List from a array using the Array.asList(array[]) method I’ve stumbled on that error. java.lang.UnsupportedOperationException at java.util.AbstractList.add(AbstractList.java:131) at java.util.AbstractList.add(AbstractList.java:91) Then I remember this, list created by the Arrays.asList method are immutable Same goes for empty lists. So instead create a arraylist : List<String> list = new ArrayList<String>(Arrays.asList(split));
Posted in java, prog | Tagged arraylist, java, java.util.List |
By Chris on September 28, 2014
Comparing and sorting Strings might not work out like you expected specially when your dealing with a language other than English. Normally comparing strings in done with simple Unicode ordering. If you want to have localized ordering (the kind expected by an end user) you need to use a Collator. Commonly used String methods such […]
Posted in java, prog | Tagged collator, java, sorting, String |
By Chris on September 2, 2014
If you happen to rename your folder that contain your jsp and js, don’t forget to update the struts config (and the tiles). This will save your precious time even hours …
Posted in java | Tagged java, javascript, js, jsp, struts |
Recent Comments