Categories
Development

Do until loop in Spring reactor

Reactor 3.1.0 added a brand new and shiny operator expand, which solved by long term dilemma about how to implement downloading of paginated REST endpoints without recursion.

Categories
Development

Pagination with Github, Reactor and Spring Webclient

I wanted to go beyond the basic example of extracting a single rest result from github rest API which is shown everywhere these days. So here it is, a simple base for Reactor API for Github. It showcases basic functionality of flatMap, recursive calls, custom subscribtion rate limiter implementation.

Categories
Development

Spring Reactor common mistakes

I recently gotten fond of Spring Reactor, reactive java library used by Spring 5.0. There is a lot of resources out there which describe it, so I’m not going to repeat the internet here. But in short it makes any asynchronous development a LOT easier and I dare to say its the first library which makes it almost trivial. There is a catch, learning curve is steep. And when I mean steep I mean it took me at least half a year (senior java dev) to wrap my head around it. Me and my colleagues made some stupid mistakes so here are 4 so far, will add more in the future.

Categories
Development

Google analytics report parsing in Java 8

Google has deprecated Google Analytics API v3 in favor of its new reporting API (V4). New API is quite universal and easy to use and its java library gets the job done well with one exception: mapping result to Java types. It returns everything in strings and you have to parse the Reports yourself and map the values to your object. I recently had to load quite a lot of daily statistics from google analytics so I wrote a simple class which does this dirty work for me.

Categories
Development

NullPointerException thrown from out of nowhere

Today I spent 30 minutes debugging a code which was throwing a null pointer exception. I never seen it before so I ruled out the obvious suspects and checked during several debugging runs what is and what actually is not null. It was not my code and it looked a bit shady, but everything seemed fine in debugger and more importantly, nothing seemed to be null.

Categories
Development

Instrumentation Testing with Dagger and Espresso

dagger_espressoOver the Christmas holidays Google has integrated the Espresso testing framework into its android built tools and bumped the version to 2.0. Old espresso maven repos went dead because of that which forced us to temporally move to Jake Wharton’s repo until we got the time to move. I was the fortunate one who had to make the switch. This post describes the pitfalls of the upgrade.

Categories
Development

SMPP SMSC simulator

open-source-softwareFew months ago I have brushed off dust out of one of my pet projects which I wrote back when I was working on Acision SMS gateway: SMPP SMSC simulator. SMPP is a binary protocol for sending SMS messages. It’s still very much used in Telco so this simulator might be of use to some people.

Categories
Development

x509 certificates in few links

Certificates were always a little fleeing mistery to me. I always wanted to know more about them and never found the time. Few weeks back I finally kicked myself and spend one day with the certificates, signatures, signing and all that jazz. Here is a list of excelent sources.

Categories
Development

MySQL query logging on Windows 7

I just spent 30 minutes on a seemingly trivial task. I wanted to see what the JPA is doing to my database so I decided to turn on mysql query logging. It should be simple three step operation:

  • Edit my.ini
  • add “log=query.log”.
  • restart Mysql

Tried it, did not work. I tried to put the my.ini file to all directories that MySQL is suposed to look into (c:\, c:\windows\, install dir). Nothing worked. Finally I checked the MySQL service startup commands and to my surprise there was

–defaults-file=”C:\ProgramData\MySQL\MySQL Server 5.5\my.ini”

I used standard MySQL installation for Windows, installed it as a service so I really do not understand that this is not mentioned in manual. Or I can not read. Anyway after I edited this file and put the “log=query.log” under [mysqld] group, restarted the server and finally the log was created in

c:\ProgramData\MySQL\MySQL Server 5.5\data\query.log

Heureka.

Categories
Development

How to enable JPA 2.0 on Weblogic

I am experimenting with JPA 2.0 using eclipselink. When I tried to call my webservice, weblogic thrown a nasty error reporting “unknown method” when trying to call EntityManager method.

Well I asked google … it seems that Weblogic is shipped with JPA 1.0 by default. The official doccumentation on weblogic is confusing and provides code which is too complicated for what it really does. All you really to do is modify startWebLogic.cmd file:

[sourcecode]
c:\Oracle\Middleware\user_projects\domains\base_domain\bin\startWebLogic.cmd
[/sourcecode]

and add to beginning:

[sourcecode]
SET wls_modules=c:\Oracle\Middleware\modules\
set PRE_CLASSPATH=%wls_modules%javax.persistence_1.0.0.0_2-0-0.jar;%wls_modules%com.oracle.jpa2support_1.0.0.0_2-0.jar
echo PRE_CLASSPATH=%PRE_CLASSPATH%
[/sourcecode]
Be sure to use your paths. Restart weblogic and you are good to go.