Skip to content
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.

Commit

Permalink
Merge pull request #49 from omgapuppy/master
Browse files Browse the repository at this point in the history
Remove LogTooLongException
  • Loading branch information
StephenHynes7 committed Jun 24, 2016
2 parents 5b74cff + e77b906 commit d43f500
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 20 deletions.
8 changes: 8 additions & 0 deletions .travis.yml
Expand Up @@ -4,3 +4,11 @@ jdk:
- openjdk7
- oraclejdk7
- oraclejdk8
before_install:
# override default MAVEN_OPTS
- echo "MAVEN_OPTS='-Xms1g -Xmx2g -XX:MaxPermSize=512m'" > ~/.mavenrc
# Fix OpenJDK buffer overflow
- cat /etc/hosts # optionally check the content *before*
- sudo hostname "$(hostname | cut -c1-63)"
- sed -e "s/^\\(127\\.0\\.0\\.1.*\\)/\\1 $(hostname | cut -c1-63)/" /etc/hosts | sudo tee /etc/hosts
- cat /etc/hosts # optionally check the content *after*
10 changes: 10 additions & 0 deletions pom.xml
Expand Up @@ -72,6 +72,16 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<!-- Travis build workaround -->
<forkCount>1</forkCount>
<argLine>${surefire.jvm.params}</argLine>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
Expand Down
28 changes: 15 additions & 13 deletions src/main/java/com/logentries/net/AsyncLogger.java
Expand Up @@ -270,53 +270,53 @@ public int getDataHubPort() {
*
* @param logHostName
*/
public void setLogHostName(boolean logHostName) {
this.logHostName = logHostName;
public void setLogHostName(boolean logHostName) {
this.logHostName = logHostName;
}

/**
* Gets value of the switch that determines whether to send HostName alongside with the log message
*
* @return logHostName switch value
*/
public boolean getLogHostName() {
return this.logHostName;
public boolean getLogHostName() {
return this.logHostName;
}

/**
* Sets the HostName from configuration
*
* @param hostName
*/
public void setHostName(String hostName) {
this.hostName = hostName;
public void setHostName(String hostName) {
this.hostName = hostName;
}

/**
* Gets HostName parameter
*
* @return Host name field value
*/
public String getHostName() {
return this.hostName;
public String getHostName() {
return this.hostName;
}

/**
* Sets LogID parameter from config
*
* @param logID
*/
public void setLogID(String logID) {
this.logID = logID;
public void setLogID(String logID) {
this.logID = logID;
}

/**
* Gets LogID parameter
*
* @return logID field value
*/
public String getLogID() {
return this.logID;
public String getLogID() {
return this.logID;
}

/**
Expand Down Expand Up @@ -419,7 +419,9 @@ public void addLineToQueue(String line) {
}

private void addLineToQueue (String line, int limit) {
if (limit == 0) { throw new LogTooLongException(); }
if (limit == 0) {
dbg("Message longer than " + RECURSION_LIMIT);
return; }

//// Check credentials only if logs are sent to LE directly.
// Check that we have all parameters set and socket appender running.
Expand Down
7 changes: 0 additions & 7 deletions src/main/java/com/logentries/net/LogTooLongException.java

This file was deleted.

18 changes: 18 additions & 0 deletions src/test/java/com/logentries/net/AsyncLoggerTest.java
@@ -1,6 +1,9 @@
package com.logentries.net;

import org.junit.Test;

import java.util.Random;

import static org.junit.Assert.*;

public class AsyncLoggerTest {
Expand All @@ -17,6 +20,21 @@ public void testGetAndSetToken()
}

@Test
public void testOversizeMessage()
{
AsyncLogger async = new AsyncLogger();
char[] chars = "abcdefghijklmnopqrstuvwxyz".toCharArray();
StringBuilder sb = new StringBuilder();
Random random = new Random();
for (int i = 0; i < 2100000; i++) {
char c = chars[random.nextInt(chars.length)];
sb.append(c);
}
String output = sb.toString();
async.addLineToQueue(output);
}

@Test
public void testGetAndSetHttpPut()
{
AsyncLogger async = new AsyncLogger();
Expand Down

0 comments on commit d43f500

Please sign in to comment.