Webindex PageLoader null handling

Open
#7 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
38/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
java
Domain
backend

Research direction

Start with PageLoader.updatePage, specifically the implementation shown in the issue, and the supplied PageLoaderTest. Run the null-page and empty-page tests to establish current behavior; done means null input is handled without dereferencing it while the existing empty-page IllegalArgumentException behavior remains covered.

Written by the indexing model from the issue text.

Description

webindex.data.fluo.PageLoader does not check for null inputs. When dereferencing the object to see if it is empty it doesn't first check to make sure the object exists. I wrote a simple test to show this below.

This is line 45 - 50 that shows why it happens

public static PageLoader updatePage(Page page) {
    Preconditions.checkArgument(!page.isEmpty(), "Page cannot be empty");
    PageLoader update = new PageLoader();
    update.action = Action.UPDATE;
    update.page = page;
    return update;
  }
package webindex.fluo;

import org.junit.Test;

import webindex.core.models.Page;
import webindex.data.fluo.PageLoader;

public class PageLoaderTest {

	@Test
	public void testNullPage() {
		Page p = null;
		PageLoader loader = PageLoader.updatePage(p);
	}
	
	@Test(expected = IllegalArgumentException.class)
	public void testEmptyPageThrowsIllegalArgument() {
		Page p = Page.EMPTY;
		PageLoader loader = PageLoader.updatePage(p);
	}

}
Dominant language
Java
Stars
2
Forks
7
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from apache/accumulo-fluo-examples

All issues in apache/accumulo-fluo-examples

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.