Java
Oracle 11.2は10行。*1 By default, when Oracle JDBC runs a query, it retrieves a result set of 10 rows at a time from the database cursor. This is the default Oracle row fetch size value. Oracle 21は10行。*2 By default, when Oracle JDBC run…
JaCoCoはC1 Coverageが取れると言っておきながら実際に取れるのはC1(分岐網羅)でなくC2(条件網羅)という問題がある。 この問題に対して、JaCoCo組込みのReportGeneratorを改造するか、またはReportGeneratorを改造するかして、コードカバレッジのデータ…
背景 JavaによるOLTP処理の中で、「別サーバのauthorized_keysに指定されたコマンドをパスフレーズなしのSSH鍵でキックし、その戻り値を確認する」という処理を行いたい場合、外部コマンドとしてSSHを起動するのはいかにも手間がかかる。 そこで、Javaで実装…
In C, you can get the name of the binary file called from the shell with argv[0]. In Java, it seems there is no obvious way to get the equivalent: the name of the class that has the entry-point main() class. I made three options, but none …
Antには、コンパイル環境のJavaバージョンを判定・取得するJavaEnvUtilsというクラスがあるが、このクラスは最新の1.10.12でもJava 12までしか定義がない。 https://github.com/apache/ant/blob/master/src/main/org/apache/tools/ant/util/JavaEnvUtils.jav…
Java ReportGeneratorでは、分岐カバー率50%を超える行は緑色で表示されてしまい、条件網羅を記録するJaCoCoのようなツールでは逆に表示が分かりにくいという問題があることが分かったので、JaCoCoはEclipseの画面をそのまま表示。 JaCoCoはバイトコード単位…
結論 JaCoCoでは行単位のC1カバレッジが取れないのだ、OpenCloverでは行単位のC1カバレッジが取れそう。C1が100%実行されていないのに100%と表示されてしまうといった問題もなさそう。 手順 手元の環境ではなぜかEclipseでOpenCloverを使う手順が上手く動か…
EclipseからTomcatにアプリをデプロイしたんだけど、思った通りに動いていないように見える……ちゃんとデプロイされてるんだっけ?などというときに調べるフォルダ。 アプリケーションの展開先 (Eclipseのワークスペース)/.metadata/.plugins/org.eclipse.wst…
satob.hatenablog.com application.propertiesにspring.servlet.multipart.max-file-size=100のように設定することでサイズ制限設定可能。 Spring Frameworkのファイルアップロード機能は、Webコンテナが持っているmultipartリクエストの処理機能をそのまま…
spring.servlet.multipart.max-file-size=100を設定した状態で、以下のようなControllerに様々なmultipart/form-dataリクエストを送信して結果を比較した。 @PostMapping("/upload") public String handleFileUpload(@RequestParam("file") MultipartFile fi…
For load test If you want to run a load test in a JUnit test case and get maximum memory consumption or GC count as a Java variable, the way to do it doesn't seem to be. For memory consumption of whole Java VM If you want to run some tests…
JSPやXMLなどのマークアップ言語に対して、たとえば JSPで<form:password>タグのshowPassword属性はtrueにしたらダメ JETTでxlsxファイルに<jt:comment>タグは使ったらダメ Apache FOPで<fo:external-graphic>タグのsrc属性に#や%や空白が入っていたらダメ のような、「XML SchemaやDTDでは禁止されていないけ</fo:external-graphic></jt:comment></form:password>…
RHEL標準の機能のみで、外から追加のモジュール等を導入することなしに採用可能な方法の候補を列挙してみた。また商用JavaEEサーバの場合は専用の機能があるケースもありそうだが、Tomcatの場合に使える方法の候補も調べてみた。 制御箇所の候補 TCP/IPレベ…
GlassFishはEPL 2.0とGPLv2のデュアルライセンスである。ここで、GPLv2にはクラスパス例外が付いている*1。わざわざクラスパス例外が付いているってことは、「クラスパス例外が付いていないGPLのJavaアプリケーションサーバでは、その上で動かすプログラムも…
Background By using the .bat file from here, you can run a PowerShell script by just click the .bat file. reosablo.hatenablog.jp Problem When you are trying to run the .bat file from Java ProcessBuilder class like this, the .bat file will …
CyberChef Unescape string is equivalent to native2ascii -reverse. CyberChef Escape string is almost equivalent to native2ascii. Escape level should be "Special chars". native2ascii never escape Escape single quotes, double quotes, or backt…
個人情報を含むデータをもとにプログラムのテストデータを作成する場合などには、データの匿名化が必要になります。個人情報保護委員会「個人情報の保護に関する法律についてのガイドライン(匿名加工情報編)」*1には、管理用IDなど特定の個人の識別に使え…
Context You are building a Java web application with JMS. You have added a reference to JMS queue with <res-ref-name>xxx/yyy/zzz</res-ref-name> in web.xml. You have changed the configuration file from standalone.xml to standalone-full.xml to use JMS module. You have a…
Test for RFC 5322: https://gist.github.com/satob/0dc003aefe020d5f1e9263bd7e173f9f (with regexp in http://www.din.or.jp/~ohzaki/mail_regex.htm#RFC) Test for RFC 821: https://gist.github.com/satob/8c5a42cf636732d81b850b58e8808eef (with regex…
じゃぁメールアドレスのバリデーションってどうやったらいいのさ、という話。 satob.hatenablog.com もちろんバリデーションをした後には、メールアドレスの実在性確認のために実際にメールを送信します*1。その前段で、画面に表示したときにセキュリティ的…
Javadoc of JavaMail API says InternetAddress class uses "the syntax of RFC822". https://javaee.github.io/javamail/docs/api/javax/mail/internet/InternetAddress.html Then how about actual implementation? Is it different from some other email…
A: Around 568 (But sometimes it could be compile) BeanWithSoManyFields.java · GitHub This class causes java.lang.StackOverflowError like this: java.lang.StackOverflowError at java.lang.reflect.Field.get(Field.java:393) at lombok.core.AST.b…
You will get error when you run following Maven command from Windows PowerShell: PS C:\workspace> mvn -B archetype:generate -DgroupId=com.example -DartifactId=hajiboot -Dversion=1.0.0-SNAPSHOT -DarchetypeArtifactId=maven-archetype-quicksta…
Both of String#split() in Java and -split operator in PowerShell take regex as argument, and split string into a list or an array, but there is some difference in behavior when you pass an empty string as argument. In Java: System.out.prin…
JIS X 0213など、シフトJISやマイクロソフト コードページ932以外の文字をプログラム上で紙に印刷する場合には、入力された文字列を枠内に確実に収めるため、文字数を正しくカウントする必要があります。 JIS X 0213では複数のコードポイントで1文字を表す文…
Java application uses ClassLoaders in parent-first mode. On the other hand, some JavaEE Application Servers are not parent-first mode in default, and/or have preferences to configure ClassLoader behavior. # Application Server Default mode …
JCache cannot save the order of insertion. You should use LinkedHashMap for that purposes. JCache cannot update whole entries in a cache atomically. You should use AtomicReference or some locking mechanisms for that purpose. (Ofcourse you …
For example, in PushOperation.java in EGit, PushOperationSpecification contains LinkedHashMap<URIish, Collection<RemoteRefUpdate>>. So you can join all remote name with Stream API like: String specs = this.specification.getURIs().stream() .map(uri -> this.specification.getRe</uriish,>…
Context You can use lambda as lazy evaluation syntax in Java. Problem You can wrap RuntimeException with lambda like (it shows "omit exception"): import java.util.function.Supplier; public class OmitRuntimeException { public static void ma…
Java Patten class (regexp) supports POSIX character classes like \p{XDigit}. They are very useful when you want to check hex strings. In Java API Document, POSIX character classes say (US-ASCII only). What does it mean? https://docs.oracle…