Found a surprising issue in Xtext.
Apparently, Xtext generator has this AntlrToolFacade class that tries to download http://download.itemis.com/antlr-generator-3.2.0-patch.jar and save it in current dir as .antlr-generator-3.2.0-patch.jar to then load classes out of it.
Which is pretty crazy.
First of all, if you use Nexus or Artifactory to make sure your builds do not depend on thirdparty resources being up – this breaks it.
Second, downloading something over HTTP without any checksums and stuff is as unsafe as you can think. The issue occurred in a first place because Itemis started to redirect from HTTP to HTTPS link on this path – but the code that does download can’t even follow redirects :facepalm: And the “fix” that has been made was to disable redirect and still serve the JAR over HTTP (counts as a quickfix, but otherwise – :double-facepalm: ).
And in general, having URLs hardcoded is just ugly.
So, quickest solution is to simply commit antlr-generator-3.2.0-patch.jar as .antlr-generator-3.2.0-patch.jar into the root of your project – so that it would not be downloaded during builds.
If you have a better idea though – drop me a comment ;-)
I’ve shot a few day-to-night timelapses recently and had an idea to automate process of combining those images into one that would display the day-to-night transition from left to right.
I’ve used groovy shell for scripting the thing out quickly, and here is the result: Continue reading
I’ve just run into a weird problem where RabbitMQ server was running EXTREMELY slow on my laptop for no apparent reason.
After trying a bunch of things and googlig for a while I’ve found out that possible reason for that might be slow host resolution. But everything was running on a localhost!
I’ve checked my /etc/hosts and found out… Well, when I’ve upgraded my MacBook Pro laptop I’ve imported all stuff from previous one (using Apple’s migration assistant), but also did change the new laptop’s network name to avoid conflicts with the old laptop being on the same network. But I did not update /etc/hosts accordingly – it only had 127.0.0.1 associated with the old network name.
Apparently, this is a big deal for RabbitMQ. I’ve been running it like that for more than a month and had no issues with any software whatsoever so far – but RabbitMQ (or possibly the underlying Erlang VM) was doing some special name resolution using my computer network name apparently, and that just didn’t work. Causing it not to report any errors though, but just run EXTREMELY (I mean it!) slow.
Today I had to build kube-state-metrics Kubernetes extra metrics exporter for Prometheus monitoring system. I wanted to build it for specific Linux (kernel) version (in my case it was Alpine Linux 3.4), and I also wanted to build a specific version of kube-state-metrics – latest stable, which is 1.3.1 currently.
I didn’t want to get latest version from master as I was not sure about it’s stability and I would have hard time re-creating the build since master would move on over time, so simply making “go get” wasn’t an option.
The process turned out to be a bit tricky – I wanted to use docker to have proper version of Go lang for Alpine Linux 3.4 while I’m on a macOS myself, but the makefile of kube-state-metrics also uses docker (for whatever silly reason that is), so I needed to build it using go build.
As it turned out, I had to do two things – install Go into Alpine 3.4 (which took some copypasting from https://github.com/docker-library/golang where they have Dockerfile for Alpine 3.7 – contents of which I used) and then get the paths right for GOPATH in order to build kube-state-metrics.
Here’s the resulting Dockerfile: Continue reading
I’ve been using successfully my 2.8″ 320×240 uTouch PiTFT with Raspberry Pi 1 and 2, but recently I’ve tried it with Pi 3 and got a 90-degree rotated touch input.
I’ve installed PiTFT support using adafruit-pitft-helper and this instruction at Adafruit. However, if did not help with the rotated input issue.
What did help was this StackOverflow answer and this manual on transformation matrix.
In short, I had to edit /usr/share/X11/xorg.conf.d/40-libinput.conf adding this to “libinput touchscreen catchall” section:
Option "TransformationMatrix" "0 -1 1 1 0 0 0 0 1"
This is a transformation matrix for 90 degree rotation of screen, which was the case for me.
Once done, the touchscreen input has got proper rotation.
Spring MVC has nice feature for adding security controls to Controller methods via @PreAuthorize annotation, but there’s an interesting problem that might occur when those methods are mistakenly marked as private or final.
Spring uses CGLib proxy to add calls to authorization logic declared in @PreAuthorize before calling actual controller method, but CGLib fails to process private or final methods, producing error like this in console:
2016-11-28 17:19:14.186 INFO 97079 --- [ main] o.s.aop.framework.CglibAopProxy : Unable to proxy method [public final java.util.Map com.package.controller.MyController.someMethod(javax.servlet.http.HttpServletResponse)] because it is final: All calls to this method via a proxy will NOT be routed to the target instance.
Well, so far so good – nothing special happens, all is more/less expected.
The problem though is that among most console output produced by Spring MVC yet another INFO log line rarely gets noticed. So what actually happens with those private/final methods of SpringMVC controller? Here weird stuff begins.
Say you’re writing a controller method that has a @PreAuthorize added to it, and accidentally copy-paste in a return type with final predicate before it, thus making your method final. You miss the log line in console because it’s just INFO among many other similar lines. And then… all autowired or otherwise injected fields of a controller are somehow null when calling only that particular method. But we know that in Spring MVC every controller is a singleton, so how is this even possible?
The issue appears to be that we’re actually calling methods on a CGLib proxy, that can’t pass them down to actual controller class instance. But proxy itself looks just like the controller class instance, except all fields that were supposed to be injected by Spring are null. A weird looking symptom which does not intuitively lead us to the cause of the problem.
But once one encounters this issue, I bet one remembers well next time what it is a symptom of.
P.S. I’ve encountered this issue with final method, but seems other people had same issue with private methods.