Tuesday, May 29, 2018

Share the knowledge - in a fun way (with pictures)

At TouK we have so called TouK's Thursday Breakfast. It's name comes from King Stanisław II August's idea of Thursday Dinners. Our implementation is as a breakfast as it takes time at 10 am.
We gather from time to time at Thursday to discuss some interesting topics that are non-technical. For example we summarize projects, discuss important events in company's life, etc.

Technical topics we discuss on Fridays during TouK Weekly Workshops.

This time we tried to activate all our employees to share thier sources of knowledge - interesting Internet addresses: pages, blogs, vlogs etc. It could be done with an "ordinary" Google Forms poll but we love to do it differently. We've made a voting cards and voting box.

We've put it in the kitchen and made a call to action with special posters.

On that very day most of the company came and we've discussed all proposals.

There were two hosts - me and my colleague Tomasz. We've pulled out every card and asked the author to say a few words about this particular knowledge source. We've also presented this page on projector wall. Lot's of new ideas appeared.

But where's the fun? 
This was a surprise for all. Me and Tomasz were disguised as company owners. We were  acting like them even with some typical gestures. People were laughting all the time and it was really nice.

Some tips and takeaways?

  • Prepare yourself. Take all results and visit them before to have a consistent list of pages. Let's waste no time on googling for proper resource. 
  • Prepare poster or email everybody that the meeting will take place.
  • Have some snacks and/or soft-drinks. This should be a nice meeting. 
  • Don't declaim. Have a chat and share opinions. Discuss. 
  • Make jokes. Have fun.

Grande finale
I really encourage you to share knowledge. I doesn't have to be so serious and boring.

Me and Tomasz :)

Saturday, January 9, 2016

Error:(, ) java: package edu.umd.cs.findbugs.annotations does not exist using Lombok

If you have an error during compilation in IntelliJ Idea and/or maven/gradle

Error:(X, Y) java: package edu.umd.cs.findbugs.annotations does not exist

you've enabled FindBugs Suppress Warnings in lombok.config:

lombok.extern.findbugs.addSuppressFBWarnings = true

but you forgot to add FindBugs to your maven/gradle config...

You might either remove config directive or add FB dependency.

Friday, September 4, 2015

What's the cause of your problem?

Most of exceptions has a few constructors including those with cause exception.
But what if you have to throw an exception that has no cause in constructor? You try to survive:

 Exception cause = new Exception("I'm the cause!");
 SSLHandshakeException noCauseExc = new SSLHandshakeException(String.format("SSL problem: [%s]", cause.getMessage()));

...and you lose stacktrace which is cruicial!

There's a solution Throwable::initCause(). Check this code and have cause tailed to your exception

import javax.net.ssl.SSLHandshakeException;

 * Created by bartek on 04.09.15.
public class Cause  {

    public static void main(String[] args) {

        Exception cause = new Exception("I'm the cause!");
        SSLHandshakeException noCauseExc = new SSLHandshakeException(String.format("SSL problem: [%s]", cause.getMessage()));

        SSLHandshakeException withCauseExc = new SSLHandshakeException("Another SSL problem");

Tuesday, August 25, 2015

Restart or power off Rasperry PI with REST call

If you need to restart or power off your RPi remotely (or through local application's call) here's a simple way


Details and code at  https://github.com/zdanek/raspiPowerServer

Monday, April 20, 2015

Abstract method in Enums

Did you know that you can do that?

  private static enum DynamicProperty {

        cacheManagerName {
            void applyChange(final PropertyChangeEvent evt, final RuntimeCfg config) {
                config.cacheManagerName = (String) evt.getNewValue();
        defaultCacheConfiguration {
            void applyChange(final PropertyChangeEvent evt, final RuntimeCfg config) {
                LOG.debug("Default Cache Configuration has changed, previously created caches remain untouched");

        abstract void applyChange(PropertyChangeEvent evt, RuntimeCfg config);

I think it's nice because it allows you to customize Enum's behavior or perform other actions on use. 

Piece of code taken from EhCache Configuration (line 118 and further).

Thursday, April 16, 2015

EhCache config with BeanUtils

BeanUtils allows you to set Bean properties.
If you have configuration stored in a Map it's tempting to use BeanUtils to automagically setup EhCache configuration.
Sadly this class has mixed types in setters and getter and thus BeanUtils that use Introspector behind won't get getter and setter pairs properly. It will get only getters and thus inform you that these properties are read only: "Skipping read-only property".

My fast solution is to use BeanUtils and have a fallback to Reflection.

public static void setProperty(Object obj, String propertyName, Object propertyValue, boolean silently) {
        try {
            PropertyDescriptor desc = PropertyUtils.getPropertyDescriptor(obj, propertyName);
            Method writeMethod = desc.getWriteMethod(); 
            if (writeMethod == null) {
                writeMethod = getAlternativeWriteMethod(obj, propertyName, propertyValue.getClass());
            if (writeMethod == null) {
                if (silently) {
                throw new IllegalArgumentException("Can't find writerMethod for " + propertyName);

            if (LOG.isTraceEnabled()) {
                LOG.trace(String.format("Setting %s property of %s", propertyName, obj.getClass().getSimpleName()));
            writeMethod.invoke(obj, propertyValue);
        } catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
            throw new IllegalArgumentException("Error when setting object property.", e);

    private static Method getAlternativeWriteMethod(Object obj, String propertyName, Class paramClass) throws NoSuchMethodException {
        String setterMethod = "set" + propertyName.substring(0, 1).toUpperCase() + propertyName.substring(1);
        Method m; 
        if ((m = getMethod(obj, paramClass, setterMethod)) != null) {
            return m;
        Class altClass = paramClass.isPrimitive() ? ClassUtils.primitiveToWrapper(paramClass) : ClassUtils.wrapperToPrimitive(paramClass);
        if ((m = getMethod(obj, altClass, setterMethod)) != null) {
            return m;
        return null;

    private static Method getMethod(Object obj, Class paramClass, String setterMethod) {

        try {
            return obj.getClass().getMethod(setterMethod, paramClass);
        } catch (NoSuchMethodException e) {
            return null;

I will think about PR to Configuration class but it's complicated as EhCache 2.x is not present on GitHub.

Thursday, September 5, 2013


TouK zaangażował się w produkcje filmową.
Polecam stronę www.dostawcyfilm.pl