Category: Programming Language
-
JEE Security: Disabling HTTP OPTIONS method
PROBLEM HTTP OPTIONS method is used to provide a list of methods that are supported by the web server. For example, the following shows both GET and HEAD are allowed on the given link:- Enabling OPTIONS may increase the risk of cross-site tracing (XST)… see OWASP’s Test HTTP Methods (OTG-CONFIG-006). SOLUTION There are several ways Read More…
-
Maven GPG Plugin: Prevent Signing Prompt or “gpg: signing failed: No such file or directory” Error
PROBLEM Given the following Maven settings.xml:- … and the following Maven GPG Plugin configuration in pom.xml:- When running mvn clean deploy, you either get a prompt for you to enter the GPG passphrase:- … or, get the following error:- The long story short, Maven GPG Plugin isn’t using the passphrase defined in the Maven settings.xml… Read More…
-
Groovy: Copying Properties Between Two Beans
PROBLEM Given two beans… There are several ways to copy properties from one bean to another:- SOLUTION Groovy provides a helper class to solve this problem called InvokerHelper. The advantage of using this is there’s no need to import yet another dependency and it still allows us to keep our code concise. Scenario 1: Both Read More…
-
Spring MVC: Failed to convert value of type ‘java.lang.String’ to required type ‘java.time.LocalDateTime’
PROBLEM Given the following controller … When executing … … the web service call returns 400 Bad Request with the following error in the console log:- SOLUTION One solution is to change the data type from java.time.LocalDateTime to java.lang.String before parsing it to java.time.LocalDateTime. However, it is a little more verbose than I like. A Read More…
-
MS SQL Server + Hibernate 5: Incorrect syntax near ‘@P0’
PROBLEM When upgrading to Hibernate 5, the following exception is thrown:- SOLUTION Change the MS SQL Server dialect from this… … to this … Read More…
-
ES6 + Mocha + Sinon: Mocking Imported Dependency
PROBLEM Let’s assume we have the following 2 files:- apis.js service.js Let’s assume we want to test the logic in service.js without using nock to mock the HTTP call in apis.js. While proxyquireify allows us to mock out the apis.js dependency in service.js, sometimes it is a little more complicated than needed. SOLUTION A simpler Read More…