Friday, August 29, 2014

Examine Apache configuration locations on server

-root@centos-server ~]# which httpd
/usr/sbin/httpd


[root@centos-server ~]# /usr/sbin/httpd -V | egrep ROOT\|SERVER_CONFIG
-D HTTPD_ROOT="/etc/httpd"
-D SERVER_CONFIG_FILE="conf/httpd.conf"


[root@centos-server ~]# grep  "^[iI]nclude" /etc/httpd/conf/httpd.conf
Include conf.d/*.conf

[root@centos-server ~]# ls -la /etc/httpd/conf.d/
total 16
drwxr-xr-x. 2 root root 4096 Aug 14 21:06 .
drwxr-xr-x. 4 root root 4096 Aug 14 21:06 ..
-rw-r--r--. 1 root root  392 Jul 23 14:18 README
-rw-r--r--. 1 root root  299 Jul 18 06:27 welcome.conf
...... here will be your other confs that are included

[root@centos-server ~]#  less /etc/httpd/conf.d/welcome.conf 
# This configuration file enables the default "Welcome"
# page if there is no default index page present for
# the root URL.  To disable the Welcome page, comment
# out all the lines below.
#
<LocationMatch "^/+$">
    Options -Indexes
    ErrorDocument 403 /error/noindex.html
</LocationMatch>


Wednesday, July 2, 2014

false negatives and false positives


Result of validation could be false negatives (no issue reported) or false positives (incorrect issues reported).

Friday, June 27, 2014

Google Java Style - mandatory braces rules

During development of Checkstyle configuration for Google Java Style,  we found two rules that are looks like conflicting . 

In 4.1.1 Google say:
Braces are used with if, else, for, do and while statements, even when the body is empty or contains only a single statement.

in 4.1.3 Google say:
An empty block or block-like construct may be closed immediately after it is opened, with no characters or line break in between ({}), unless it is part of a multi-block statement (one that directly contains multiple blocks: if/else-if/else or try/catch/finally).

So in 4.1.1 IF-ELSE could be {}, but in 4.1.3 there is unclear "unless" that either conflict with 4.1.1 or mean smth else that it not described.

After long discussion with friends and investigation :

Rule 4.1.1 tell us to always use braces for statements that use blocks

// BAD
if () {
  ...
} else
  i++;

It must be
// GOOD
if () {
  ...
} else {
  i++;
}

// it is OK, old fashioned but ok
int index = 0;
for (; index < s.length() && s[index] != 'x'; index++) {}

// OK, side effect in condition expression is bad design , but it is not matter of style/formatting 
while ((r = in.read()) != 0) {}

So ELSE is just another structure that could have braces so it have to have braces no matter what.


Rule 4.1.3 extend 4.1.1 and demand that braces should not be empty in multi-block statements, small wording conflict in ELSE case is not intentional and if apply rules in sequence 4.1.1 and then 4.1.3 all will be fine:

// BAD
try {
  doX();
} catch (Exception e) {}

// BETTER
try {
  doX();
} catch (Exception e) {
  // Here's why I'm swallowing this exception
}

// BAD
if (expr) {} else {
  doSomething();
}

// BETTER
if (expr) {
  // Here's why I'm not doing anything here....
} else {
  doSomething();
}

Get java process heap dump and analyse it by jhat


1. Get all java processes ids
17:17 ~/java $ jps -vm
14970 Jps -vm -Dapplication.home=/usr/lib/jvm/java-7-oracle -Xms8m
8850 org.eclipse.equinox.launcher_1.3.0.v20130327-1440.jar -data /home/rivanov/workspace -os linux -ws gtk -arch x86_64 -showsplash /home/rivanov/ ..................... -Dosgi.requiredJavaVersion=1.6 -XX:MaxPermSize=256m -Xms40m -Xmx512m

2. generate heap dump for application, in my case it is Eclipse.
17:19 ~/java $ jmap -dump:format=b,file=eclipse_heap.bin 8850
Dumping heap to /home/rivanov/java/git/dmt/eclipse_heap.bin ...
Heap dump file created

3. run jhat tool from JDK to analyse heap dump.
17:19 ~/java $ jhat eclipse_heap.bin 
Reading from eclipse_heap.bin...
Dump file created Fri Jun 27 17:19:37 PDT 2014
Snapshot read, resolving...
Resolving 1548547 objects...
Chasing references, expect 309 dots.....................................................................................................................................................................................................................................................................................................................
Eliminating duplicate references.....................................................................................................................................................................................................................................................................................................................
Snapshot resolved.
Started HTTP server on port 7000
Server is ready.


4. Open in browser "http://localhost:7000/".
jhat is far from fancy heap dump analyser in comparison to Eclipse's MAT, jvisualvm, ...... but it is provided together with JDK and nothing should be installed .


Saturday, June 14, 2014

"Skipping JaCoCo execution ...." problem in maven project


For Checkstyle project I decided to use coveralls.io service to show UTs coverage as banner.
I used that instruction to make it for java maven project. Amazing documentation with example description worked fire for simple projects(sevntu.checkstyle , dsm-maven-plugin).

But For Checkstyle I had an error:

[romani]$ mvn jacoco:report coveralls:jacoco

...

[INFO] Skipping JaCoCo execution due to missing execution data file:/home/travis/build/checkstyle/checkstyle/target/jacoco.exec

...

[ERROR] Failed to execute goal org.eluder.coveralls:coveralls-maven-plugin:2.2.0:jacoco (default-cli) on project checkstyle: I/O operation failed: /home/travis/build/checkstyle/checkstyle/target/site/jacoco/jacoco.xml (No such file or directory) -> [Help 1]


That problem is happening when jacoco failed or did not registered his agent to instrument some code and gather statistics before tests are launched. 

Problem was in surefire-plugin, that was declared as:
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.9</version>
        <configuration>
          <argLine>-Duser.language=en -Duser.country=US</argLine>
        </configuration>
      </plugin>

Proper configuration is (attention to bold part):
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.9</version>
        <configuration>
          <argLine>${argLine} -Duser.language=en -Duser.country=US</argLine>
        </configuration>
      </plugin>
.

final version of my pom.xml (see "travis" profile) and travis.yml.

Useful links that I used for investigation:

Saturday, June 7, 2014

My donation for Ubuntu 14.04


Just because it is cool and useful - 22$:

DescriptionUnit priceQtyAmount
Ubuntu Desktop$20.00 USD1$20.00 USD
...


Tip to Canonical$2.00 USD1$2.00 USD

Thursday, May 8, 2014

Maven release plugin skipped version bump



How to fix the problem - just do that version bump yourself manually, second time it will work automatically

Here is history of commands of my failed 6.6.15 and 6.6.16, and how I made it work:

git tag -d 6.6.15
git tag -d 6.6.16
git push origin :/ref/tags/6.6.15
git push origin :refs/tags/6.6.16
mvn release:clean release:prepare -Darguments='-DskipTests=true'
gitk --all
git reset HEAD~1 --hard
git clean -fx
git pull
gitk --all
mvn versions:set -DnewVersion=6.6.16-SNAPSHOT
git status
git clean -fx
git diff
git add .
git commit -m "manual version bump"
git push
mvn release:clean release:prepare -Darguments='-DskipTests=true'
git pull
git clean -fx
Another way to fix similar problem is to update maven-release-plugin to new version:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5</version>


 </plugin>

result in tag commited to remote but version bump was not happen to snapshot, see logs for details



outputs from picture provided below.


problematic launch output:
===================================================
[INFO] [INFO] Building jar: /home/rivanov/java/git/feed/extract/target/extractor-tests.jar
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Reactor Summary:
[INFO] [INFO] 
[INFO] [INFO] feed ............................................. SUCCESS [  X.XXX s]
[INFO] [INFO] feed-access ...................................... SUCCESS [  X.XXX s]
[INFO] [INFO] feed-extract ..................................... SUCCESS [  X.XXX s]
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] BUILD SUCCESS
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Total time: 4.597 s
[INFO] [INFO] Finished at: 2014-03-27T15:17:56-08:00
[INFO] [INFO] Final Memory: 34M/222M
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] Checking in modified POMs...
[INFO] Executing: /bin/sh -c cd /home/rivanov/java/git/feed && git add -- pom.xml access/pom.xml extract/pom.xml
[INFO] Working directory: /home/rivanov/java/git/feed
[INFO] Executing: /bin/sh -c cd /home/rivanov/java/git/feed && git status
[INFO] Working directory: /home/rivanov/java/git/feed











[INFO] Tagging release with the label 6.6.15...
[INFO] Executing: /bin/sh -c cd /home/rivanov/java/git/feed && git 
tag -F /tmp/maven-scm-1595271495.commit 6.6.15
[INFO] Executing: /bin/sh -c cd /home/rivanov/java/git/feed 
&& git push git@git.mycompany.com:feed 6.6.15
[INFO] Working directory: /home/rivanov/java/git/feed
[INFO] Executing: /bin/sh -c cd /home/rivanov/java/git/feed && git ls-files
[INFO] Working directory: /home/rivanov/java/git/feed
[INFO] Transforming 'feed'...
[INFO] Transforming 'feed-access'...
[INFO] Transforming 'feed-extract'...
[INFO] Not removing release POMs
[INFO] Checking in modified POMs...
[INFO] Executing: /bin/sh -c cd /home/rivanov/java/git/feed && git add -- pom.xml access/pom.xml extract/pom.xml
[INFO] Working directory: /home/rivanov/java/git/feed
[INFO] Executing: /bin/sh -c cd /home/rivanov/java/git/feed && git status
[INFO] Working directory: /home/rivanov/java/git/feed
[INFO] Release preparation complete.
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] feed ............................................. SUCCESS [ 11.454 s]
[INFO] feed-access ...................................... SKIPPED
[INFO] feed-extract ..................................... SKIPPED






correct launch output:
====================================================
[INFO] [INFO] Building jar: /home/rivanov/java/git/feed/extract/target/extractor-tests.jar
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Reactor Summary:
[INFO] [INFO] 
[INFO] [INFO] feed ............................................. SUCCESS [  X.XXX s]
[INFO] [INFO] feed-access ...................................... SUCCESS [  X.XXX s]
[INFO] [INFO] feed-extract ..................................... SUCCESS [  X.XXX s]
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] BUILD SUCCESS
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Total time: 4.597 s
[INFO] [INFO] Finished at: 2014-03-27T15:17:56-08:00
[INFO] [INFO] Final Memory: 34M/222M
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] Checking in modified POMs...
[INFO] Executing: /bin/sh -c cd /home/rivanov/java/git/feed && git add -- pom.xml access/pom.xml extract/pom.xml
[INFO] Working directory: /home/rivanov/java/git/feed
[INFO] Executing: /bin/sh -c cd /home/rivanov/java/git/feed && git status
[INFO] Working directory: /home/rivanov/java/git/feed

============================
[INFO] Executing: /bin/sh -c cd /home/rivanov/java/git/feed 
&& git commit --verbose -F /tmp/maven-scm-218607872.commit pom.xml access/pom.xml extract/pom.xml
[INFO] Working directory: /home/rivanov/java/git/feed
[INFO] Executing: /bin/sh -c cd /home/rivanov/java/git/feed && git symbolic-ref HEAD
[INFO] Executing: /bin/sh -c cd /home/rivanov/java/git/feed 
&& git push git@git.mycompany.com:feed test-mvn-release:test-mvn-release
[INFO] Working directory: /home/rivanov/java/git/feed
============================

[INFO] Tagging release with the label 6.6.17...
[INFO] Executing: /bin/sh -c cd /home/rivanov/java/git/feed 
&& git tag -F /tmp/maven-scm-1830116578.commit 6.6.17
[INFO] Working directory: /home/rivanov/java/git/feed
[INFO] Executing: /bin/sh -c cd /home/rivanov/java/git/feed 
&& git push git@git.mycompany.com:feed 6.6.17
[INFO] Working directory: /home/rivanov/java/git/feed
[INFO] Executing: /bin/sh -c cd /home/rivanov/java/git/feed && git ls-files
[INFO] Working directory: /home/rivanov/java/git/feed
[INFO] Transforming 'feed'...
[INFO] Transforming 'feed-access'...
[INFO] Transforming 'feed-extract'...
[INFO] Not removing release POMs
[INFO] Checking in modified POMs...
[INFO] Executing: /bin/sh -c cd /home/rivanov/java/git/feed && git add -- pom.xml access/pom.xml extract/pom.xml
[INFO] Working directory: /home/rivanov/java/git/feed
[INFO] Executing: /bin/sh -c cd /home/rivanov/java/git/feed && git status
============================
[INFO] Working directory: /home/rivanov/java/git/feed
[INFO] Executing: /bin/sh -c cd /home/rivanov/java/git/feed 
&& git commit --verbose -F /tmp/maven-scm-1562430778.commit pom.xml access/pom.xml extract/pom.xml
[INFO] Working directory: /home/rivanov/java/git/feed
[INFO] Executing: /bin/sh -c cd /home/rivanov/java/git/feed && git symbolic-ref HEAD
[INFO] Working directory: /home/rivanov/java/git/feed
[INFO] Executing: /bin/sh -c cd /home/rivanov/java/git/feed 
&& git push git@git.mycompany.com:feed test-mvn-release:test-mvn-release
============================
[INFO] Working directory: /home/rivanov/java/git/feed
[INFO] Release preparation complete.
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] feed ............................................. SUCCESS [ 11.454 s]
[INFO] feed-access ...................................... SKIPPED
[INFO] feed-extract ..................................... SKIPPED


====================================================